From d4187866db261192b82930cd561172761dcc83e4 Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Tue, 18 Jun 2013 15:05:49 -0400 Subject: Add `//scale ` command (suggested by Jordach), fix transposition description in docs. --- worldedit_commands/init.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'worldedit_commands/init.lua') diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 69e9804..f610ccb 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -631,6 +631,38 @@ minetest.register_chatcommand("/stack", { end, }) +minetest.register_chatcommand("/scale", { + params = "", + description = "Scale the current WorldEdit positions and region by a factor of positive integer with position 1 as the origin", + privs = {worldedit=true}, + func = function(name, param) + local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] + if pos1 == nil or pos2 == nil then + worldedit.player_notify(name, "no region selected") + return + end + + local factor = tonumber(param) + if not factor or factor ~= math.floor(factor) or factor <= 0 then + worldedit.player_notify(name, "invalid scaling factor: " .. param) + end + + local tenv = minetest.env + if worldedit.ENABLE_QUEUE then + tenv = worldedit.queue_aliasenv + end + local count, pos1, pos2 = worldedit.scale(pos1, pos2, factor, tenv) + + --reset markers to scaled positions + worldedit.pos1[name] = pos1 + worldedit.pos2[name] = pos2 + worldedit.mark_pos1(name) + worldedit.mark_pos2(name) + + worldedit.player_notify(name, count .. " nodes scaled") + end, +}) + minetest.register_chatcommand("/transpose", { params = "x/y/z/? x/y/z/?", description = "Transpose the current WorldEdit region along the x/y/z/? and x/y/z/? axes", -- cgit v1.2.3