minetest.register_privilege("worldedit", "Can use WorldEdit commands")\r
\r
worldedit.set_pos = {}\r
+worldedit.inspect = {}\r
\r
worldedit.pos1 = {}\r
worldedit.pos2 = {}\r
return "z", dir.z > 0 and 1 or -1\r
end\r
\r
-worldedit.inspect = true\r
-\r
minetest.register_chatcommand("/inspect", {\r
params = "on/off/1/0/true/false/yes/no/enable/disable",\r
description = "Enable or disable node inspection",\r
privs = {worldedit=true},\r
func = function(name, param)\r
if param == "on" or param == "1" or param == "true" or param == "yes" or param == "enable" then\r
- worldedit.inspect = true\r
- worldedit.player_notify(name, "node inspection is now on")\r
+ worldedit.inspect[name] = true\r
+ worldedit.player_notify(name, "node inspection enabled")\r
elseif param == "off" or param == "0" or param == "false" or param == "no" or param == "disable" then\r
- worldedit.inspect = false\r
- worldedit.player_notify(name, "node inspection is now off")\r
+ worldedit.inspect[name] = nil\r
+ worldedit.player_notify(name, "node inspection disabled")\r
else\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
end\r
})\r
\r
minetest.register_on_punchnode(function(pos, node, puncher)\r
- if worldedit.inspect then\r
- message = "node inspector: " .. node.name .. " at " .. minetest.pos_to_string(pos) .. " (param1=" .. node.param1 .. ", param2=" .. node.param2 .. ")"\r
- worldedit.player_notify(puncher:get_player_name(), message)\r
+ local name = puncher:get_player_name()\r
+ if worldedit.inspect[name] then\r
+ if minetest.check_player_privs(name, {worldedit=true}) then\r
+ message = "inspector: " .. node.name .. " at " .. minetest.pos_to_string(pos) .. " (param1=" .. node.param1 .. ", param2=" .. node.param2 .. ")"\r
+ else\r
+ message = "inspector: worldedit privileges required"\r
+ end\r
+ worldedit.player_notify(name, message)\r
end\r
end)\r
\r
return\r
end\r
\r
- local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$")\r
+ local found, _, radius, nodename = param:find("^([+-]?%d+)%s+(.+)$")\r
if found == nil then\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
return\r
return\r
end\r
\r
- local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$")\r
+ local found, _, radius, nodename = param:find("^([+-]?%d+)%s+(.+)$")\r
if found == nil then\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
return\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
return\r
end\r
+ length, radius = tonumber(length), tonumber(radius)\r
if axis == "?" then\r
axis, sign = worldedit.player_axis(name)\r
length = length * sign\r
if worldedit.ENABLE_QUEUE then\r
tenv = worldedit.queue_aliasenv\r
end\r
- local count = worldedit.hollow_cylinder(pos, axis, tonumber(length), tonumber(radius), node, tenv)\r
+ local count = worldedit.hollow_cylinder(pos, axis, length, radius, node, tenv)\r
worldedit.player_notify(name, count .. " nodes added")\r
end,\r
})\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
return\r
end\r
+ length, radius = tonumber(length), tonumber(radius)\r
if axis == "?" then\r
axis, sign = worldedit.player_axis(name)\r
length = length * sign\r
if worldedit.ENABLE_QUEUE then\r
tenv = worldedit.queue_aliasenv\r
end\r
- local count = worldedit.cylinder(pos, axis, tonumber(length), tonumber(radius), node, tenv)\r
+ local count = worldedit.cylinder(pos, axis, length, radius, node, tenv)\r
worldedit.player_notify(name, count .. " nodes added")\r
end,\r
})\r
\r
minetest.register_chatcommand("/pyramid", {\r
- params = "<height> <node>",\r
- description = "Add pyramid centered at WorldEdit position 1 with height <height>, composed of <node>",\r
+ params = "x/y/z/? <height> <node>",\r
+ description = "Add pyramid centered at WorldEdit position 1 along the x/y/z/? axis with height <height>, composed of <node>",\r
privs = {worldedit=true},\r
func = function(name, param)\r
local pos = worldedit.pos1[name]\r
return\r
end\r
\r
- local found, _, size, nodename = param:find("(%d+)%s+(.+)$")\r
+ local found, _, axis, height, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(.+)$")\r
if found == nil then\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
return\r
end\r
+ height = tonumber(height)\r
+ if axis == "?" then\r
+ axis, sign = worldedit.player_axis(name)\r
+ height = height * sign\r
+ end\r
local node = worldedit.normalize_nodename(nodename)\r
if not node then\r
worldedit.player_notify(name, "invalid node name: " .. nodename)\r
return\r
end\r
\r
- local tenv = minetest.env\r
- if worldedit.ENABLE_QUEUE then\r
- tenv = worldedit.queue_aliasenv\r
- end\r
- local count = worldedit.pyramid(pos, tonumber(size), node, tenv)\r
+ local count = worldedit.pyramid(pos, axis, height, node)\r
worldedit.player_notify(name, count .. " nodes added")\r
end,\r
})\r
return\r
end\r
\r
- local found, _, width, height, space, nodename = param:find("(%d+)%s+(%d+)%s+(%d+)%s+(.+)$")\r
+ local found, _, width, height, space, nodename = param:find("^(%d+)%s+(%d+)%s+(%d+)%s+(.+)$")\r
if found == nil then\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
return\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
return\r
end\r
+ amount = tonumber(amount)\r
if axis == "?" then\r
axis, sign = worldedit.player_axis(name)\r
amount = amount * sign\r
if worldedit.ENABLE_QUEUE then\r
tenv = worldedit.queue_aliasenv\r
end\r
- local count = worldedit.copy(pos1, pos2, axis, tonumber(amount), tenv)\r
+ local count = worldedit.copy(pos1, pos2, axis, amount, tenv)\r
worldedit.player_notify(name, count .. " nodes copied")\r
end,\r
})\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
return\r
end\r
+ amount = tonumber(amount)\r
if axis == "?" then\r
axis, sign = worldedit.player_axis(name)\r
amount = amount * sign\r
if worldedit.ENABLE_QUEUE then\r
tenv = worldedit.queue_aliasenv\r
end\r
- local count = worldedit.move(pos1, pos2, axis, tonumber(amount), tenv)\r
+ local count = worldedit.move(pos1, pos2, axis, amount, tenv)\r
\r
pos1[axis] = pos1[axis] + amount\r
pos2[axis] = pos2[axis] + amount\r
worldedit.player_notify(name, "invalid usage: " .. param)\r
return\r
end\r
+ count = tonumber(count)\r
if axis == "?" then\r
axis, sign = worldedit.player_axis(name)\r
count = count * sign\r
if worldedit.ENABLE_QUEUE then\r
tenv = worldedit.queue_aliasenv\r
end\r
- local count = worldedit.stack(pos1, pos2, axis, tonumber(count), tenv)\r
+ local count = worldedit.stack(pos1, pos2, axis, count, tenv)\r
worldedit.player_notify(name, count .. " nodes stacked")\r
end,\r
})\r
\r
if minetest.place_schematic then\r
minetest.register_chatcommand("/mtschemcreate", {\r
- params = "<filename>",\r
- description = "Creates a Minetest schematic of the box defined by position 1 and position 2, and saves it to <filename>",\r
+ params = "<file>",\r
+ description = "Save the current WorldEdit region using the Minetest Schematic format to \"(world folder)/schems/<filename>.mts\"",\r
privs = {worldedit=true},\r
func = function(name, param)\r
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]\r
})\r
\r
minetest.register_chatcommand("/mtschemplace", {\r
- params = "<filename>",\r
- description = "Places the Minetest schematic identified by <filename> at WorldEdit position 1",\r
+ params = "<file>",\r
+ description = "Load nodes from \"(world folder)/schems/<file>.mts\" with position 1 of the current WorldEdit region as the origin",\r
privs = {worldedit=true},\r
func = function(name, param)\r
local pos = worldedit.pos1[name]\r
end\r
)\r
end\r
+\r
+minetest.register_chatcommand("/clearobjects", {\r
+ params = "",\r
+ description = "Clears all objects within the WorldEdit region",\r
+ privs = {worldedit=true},\r
+ func = function(name, param)\r
+ local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]\r
+ if pos1 == nil or pos2 == nil then\r
+ worldedit.player_notify(name, "no region selected")\r
+ return\r
+ end\r
+\r
+ local count = worldedit.clearobjects(pos1, pos2)\r
+ worldedit.player_notify(name, count .. " objects cleared")\r
+ end,\r
+})\r