]> git.lizzy.rs Git - dragonfireclient.git/blob - clientmods/world/init.lua
UI Update; Added AutoTool
[dragonfireclient.git] / clientmods / world / init.lua
1 minetest.register_chatcommand("findnodes", {
2         description = "Scan for one or multible nodes in a radius around you",
3         param = "<radius> <node1>[,<node2>...]",
4         func = function(param)
5                 local radius = tonumber(param:split(" ")[1])
6                 local nodes = param:split(" ")[2]:split(",")
7                 local pos = minetest.localplayer:get_pos()
8                 local fpos = minetest.find_node_near(pos, radius, nodes, true)
9                 if fpos then
10                         return true, "Found " .. table.concat(nodes, " or ") .. " at " .. minetest.pos_to_string(fpos)
11                 end
12                 return false, "None of " .. table.concat(nodes, " or ") .. " found in a radius of " .. tostring(radius)
13         end,
14 }) 
15
16 minetest.register_chatcommand("place", {
17         params = "<X>,<Y>,<Z>",
18         description = "Place wielded item",
19         func = function(param)
20                 local success, pos = minetest.parse_relative_pos(param)
21                 if success then
22                         minetest.place_node(pos)
23                         return true, "Node placed at " .. minetest.pos_to_string(pos)
24                 end
25                 return false, pos
26         end,
27 })
28
29 minetest.register_chatcommand("dig", {
30         params = "<X>,<Y>,<Z>",
31         description = "Dig node",
32         func = function(param)
33                 local success, pos = minetest.parse_relative_pos(param)
34                 if success then
35                         minetest.dig_node(pos)
36                         return true, "Node at " .. minetest.pos_to_string(pos) .. " dug"
37                 end
38                 return false, pos
39         end,
40 })
41
42 minetest.register_globalstep(function()
43         local player = minetest.localplayer 
44         if not player then return end
45         local pos = minetest.localplayer:get_pos()
46         local wielditem = minetest.localplayer:get_wielded_item()
47         if minetest.settings:get_bool("scaffold") then
48                 minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0}))
49         end
50         if minetest.settings:get_bool("highway_z") and wielditem then
51                 local z = pos.z
52                 local positions = {
53                         {x = 0, y = 0, z = z},
54                         {x = 1, y = 0, z = z},
55                         {x = 2, y = 1, z = z},
56                         {x = -2, y = 1, z = z},
57                         {x = -2, y = 0, z = z},
58                         {x = -1, y = 0, z = z},
59                         {x = 2, y = 0, z = z}
60                 }
61                 for _, p in pairs(positions) do
62                         local node = minetest.get_node_or_nil(p)
63                         if node and not minetest.get_node_def(node.name).walkable then
64                                 minetest.place_node(p)
65                         end
66                 end
67         end
68         if minetest.settings:get_bool("fucker") then
69                 local p = minetest.find_node_near(pos, 5, "group:bed", true)
70                 if p then
71                         minetest.dig_node(p)
72                 end
73         end
74         if minetest.settings:get_bool("destroy_liquids") then
75                 local p = minetest.find_node_near(pos, 5, "mcl_core:water_source", true)
76                 if p then
77                         minetest.place_node(p)
78                 end
79         end  
80 end) 
81
82 minetest.register_cheat("Scaffold", "World", "scaffold")
83 minetest.register_cheat("HighwayZ", "World", "highway_z")
84 minetest.register_cheat("Fucker", "World", "fucker")
85 minetest.register_cheat("BlockWater", "World", "destroy_liquids")