summaryrefslogtreecommitdiff
path: root/worldedit_commands
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2013-06-18 15:05:49 -0400
committerAnthony Zhang <azhang9@gmail.com>2013-06-18 15:05:49 -0400
commitd4187866db261192b82930cd561172761dcc83e4 (patch)
tree1b821588cd7d03e1e5f37e9aa94be9faeba03a77 /worldedit_commands
parent74018dab9963af589a06441c6bd39fcef4fa564b (diff)
Add `//scale <factor>` command (suggested by Jordach), fix transposition description in docs.
Diffstat (limited to 'worldedit_commands')
-rw-r--r--worldedit_commands/init.lua32
1 files changed, 32 insertions, 0 deletions
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 = "<factor>",
+ description = "Scale the current WorldEdit positions and region by a factor of positive integer <factor> 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",