From 6eb08edd3005518f06c6c43f324399d8bed6a830 Mon Sep 17 00:00:00 2001 From: Kyle Date: Tue, 28 Aug 2012 15:57:45 -0700 Subject: Rotate now works with x/y/z/? instead of just y: "//rotate x 90" --- init.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 7bd79be..6820bbf 100644 --- a/init.lua +++ b/init.lua @@ -404,8 +404,8 @@ minetest.register_chatcommand("/flip", { }) minetest.register_chatcommand("/rotate", { - params = "", - description = "Rotate the current WorldEdit region around the y axis by angle (90 degree increment)", + params = " ", + description = "Rotate the current WorldEdit region around the axis by angle (90 degree increment)", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] @@ -414,17 +414,20 @@ minetest.register_chatcommand("/rotate", { return end - angle = tonumber(param) - if angle == nil then + local found, _, axis, angle = param:find("^([xyz%?])%s+([+-]?%d+)$") + if found == nil then minetest.chat_send_player(name, "Invalid usage: " .. param) return end + if axis == "?" then + axis = worldedit.player_axis(name) + end if angle % 90 ~= 0 then minetest.chat_send_player(name, "Invalid usage: angle must be multiple of 90") return end - local count = worldedit.rotate(pos1, pos2, angle) + local count = worldedit.rotate(pos1, pos2, axis, angle) minetest.chat_send_player(name, count .. " nodes rotated") end, }) -- cgit v1.2.3