or minetest.registered_nodes["default:" .. nodename] ~= nil\r
end\r
\r
+--determines the axis in which a player is facing, returning an axis ("x", "y", or "z") and the sign (1 or -1)\r
worldedit.player_axis = function(name)\r
local dir = minetest.env:get_player_by_name(name):get_look_dir()\r
- if dir.x > dir.y then\r
- if dir.x > dir.z then\r
- return "x"\r
+ local x, y, z = math.abs(dir.x), math.abs(dir.y), math.abs(dir.z)\r
+ if x > y then\r
+ if x > z then\r
+ return "x", dir.x > 0 and 1 or -1\r
end\r
- elseif dir.y > dir.z then\r
- return "y"\r
+ elseif y > z then\r
+ return "y", dir.y > 0 and 1 or -1\r
end\r
- return "z"\r
+ return "z", dir.z > 0 and 1 or -1\r
end\r
\r
minetest.register_chatcommand("/reset", {\r
return\r
end\r
if axis == "?" then\r
- axis = worldedit.player_axis(name)\r
+ axis, sign = worldedit.player_axis(name)\r
+ length = length * sign\r
end\r
if not worldedit.node_is_valid(pos, nodename) then\r
minetest.chat_send_player(name, "Invalid node name: " .. param)\r
end,\r
})\r
\r
-\r
minetest.register_chatcommand("/spiral", {\r
params = "<size> <node>",\r
- description = "Add Spiral at WorldEdit position 1 with size <size>, composed of <node>",\r
+ description = "Add spiral at WorldEdit position 1 with size <size>, composed of <node>",\r
privs = {worldedit=true},\r
func = function(name, param)\r
local pos = worldedit.pos1[name]\r
return\r
end\r
if axis == "?" then\r
- axis = worldedit.player_axis(name)\r
+ axis, sign = worldedit.player_axis(name)\r
+ length = length * sign\r
end\r
if not worldedit.node_is_valid(pos, nodename) then\r
minetest.chat_send_player(name, "Invalid node name: " .. param)\r
return\r
end\r
if axis == "?" then\r
- axis = worldedit.player_axis(name)\r
+ axis, sign = worldedit.player_axis(name)\r
+ amount = amount * sign\r
end\r
\r
local count = worldedit.copy(pos1, pos2, axis, tonumber(amount))\r
return\r
end\r
if axis == "?" then\r
- axis = worldedit.player_axis(name)\r
+ axis, sign = worldedit.player_axis(name)\r
+ amount = amount * sign\r
end\r
\r
local count = worldedit.move(pos1, pos2, axis, tonumber(amount))\r
return\r
end\r
if axis == "?" then\r
- axis = worldedit.player_axis(name)\r
+ axis, sign = worldedit.player_axis(name)\r
+ count = count * sign\r
end\r
\r
local count = worldedit.stack(pos1, pos2, axis, tonumber(count))\r