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"
42 minetest.register_on_dignode(function(pos)
43 if minetest.settings:get_bool("replace") then
44 minetest.after(0, minetest.place_node, pos)
50 minetest.register_globalstep(function(dtime)
52 if etime < 1 then return end
53 local player = minetest.localplayer
54 if not player then return end
55 local pos = player:get_pos()
56 local item = player:get_wielded_item()
57 local def = minetest.get_item_def(item:get_name())
58 local nodes_per_tick = tonumber(minetest.settings:get("nodes_per_tick")) or 8
59 if item:get_count() > 0 and def.node_placement_prediction ~= "" then
60 if minetest.settings:get_bool("scaffold") then
61 minetest.place_node(vector.add(pos, {x = 0, y = -0.6, z = 0}))
62 elseif minetest.settings:get_bool("highway_z") then
65 {x = 0, y = 0, z = z},
66 {x = 1, y = 0, z = z},
67 {x = 2, y = 1, z = z},
68 {x = -2, y = 1, z = z},
69 {x = -2, y = 0, z = z},
70 {x = -1, y = 0, z = z},
73 for i, p in pairs(positions) do
74 if i > nodes_per_tick then break end
75 minetest.place_node(p)
77 elseif minetest.settings:get_bool("block_water") then
78 local positions = minetest.find_nodes_near(pos, 5, {"mcl_core:water_source", "mcl_core:water_floating"}, true)
79 for i, p in pairs(positions) do
80 if i > nodes_per_tick then break end
81 minetest.place_node(p)
83 elseif minetest.settings:get_bool("autotnt") then
84 local positions = minetest.find_nodes_near_under_air_except(pos, 5, item:get_name(), true)
85 for i, p in pairs(positions) do
86 if i > nodes_per_tick then break end
87 minetest.place_node(vector.add(p, {x = 0, y = 1, z = 0}))
93 minetest.register_cheat("Scaffold", "World", "scaffold")
94 minetest.register_cheat("HighwayZ", "World", "highway_z")
95 minetest.register_cheat("BlockWater", "World", "block_water")
96 minetest.register_cheat("AutoTNT", "World", "autotnt")
97 minetest.register_cheat("Replace", "World", "replace")