1 minetest.register_chatcommand("findnodes", {
2 description = "Scan for one or multible nodes in a radius around you",
3 param = "<radius> <node1>[,<node2>...]",
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)
10 return true, "Found " .. table.concat(nodes, " or ") .. " at " .. minetest.pos_to_string(fpos)
12 return false, "None of " .. table.concat(nodes, " or ") .. " found in a radius of " .. tostring(radius)
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)
22 minetest.place_node(pos)
23 return true, "Node placed at " .. minetest.pos_to_string(pos)
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)
35 minetest.dig_node(pos)
36 return true, "Node at " .. minetest.pos_to_string(pos) .. " dug"
44 minetest.register_globalstep(function(dtime)
46 if etime < 1 then return end
47 local player = minetest.localplayer
48 if not player then return end
49 local pos = player:get_pos()
50 local item = player:get_wielded_item()
51 local def = minetest.get_item_def(item:get_name())
52 if item:get_count() > 0 and def.node_placement_prediction ~= "" then
53 if minetest.settings:get_bool("scaffold") then
54 minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0}))
55 elseif minetest.settings:get_bool("highway_z") then
58 {x = 0, y = 0, z = z},
59 {x = 1, y = 0, z = z},
60 {x = 2, y = 1, z = z},
61 {x = -2, y = 1, z = z},
62 {x = -2, y = 0, z = z},
63 {x = -1, y = 0, z = z},
66 for i, p in pairs(positions) do
67 minetest.place_node(p)
69 elseif minetest.settings:get_bool("destroy_liquids") then
70 local positions = minetest.find_nodes_near(pos, 5, {"mcl_core:water_source", "mcl_core:water_floating"}, true)
71 for _, p in pairs(positions) do
72 minetest.place_node(p)
74 elseif minetest.settings:get_bool("autotnt") then
75 local positions = minetest.find_nodes_near_under_air_except(pos, 5, item:get_name(), true)
76 for i, p in pairs(positions) do
77 if i > 8 then break end
78 minetest.place_node(vector.add(p, {x = 0, y = 1, z = 0}))
84 minetest.register_cheat("Scaffold", "World", "scaffold")
85 minetest.register_cheat("HighwayZ", "World", "highway_z")
86 minetest.register_cheat("BlockWater", "World", "destroy_liquids")
87 minetest.register_cheat("AutoTNT", "World", "autotnt")