From 174416b010cd7833edb12f7ec7db7ab8f1918bce Mon Sep 17 00:00:00 2001 From: Cy Date: Mon, 30 Jun 2014 16:13:44 -0700 Subject: Randomized set Can /set node node2 node3 and it will randomly choose between those three. --- worldedit_commands/init.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'worldedit_commands/init.lua') diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 2bbfeed..04f2f4c 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -278,22 +278,26 @@ minetest.register_chatcommand("/volume", { end, }) -local check_set = function(name, param) - local node = get_node(name, param) - if not node then return nil end - return check_region(name, param) -end - minetest.register_chatcommand("/set", { params = "", description = "Set the current WorldEdit region to ", privs = {worldedit=true}, func = safe_region(function(name, param) + local nodes = {} + + for nodename in param:gmatch("[^%s]+") do + local node = get_node(name, nodename) + if not node then + worldedit.player_notify(name, 'Could not identify node "'..name..'"') + return + end + nodes[#nodes+1] = node + end + local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] - local node = get_node(name, param) - local count = worldedit.set(pos1, pos2, node) + local count = worldedit.set(pos1, pos2, nodes) worldedit.player_notify(name, count .. " nodes set") - end, check_set), + end, check_region), }) local check_replace = function(name, param) -- cgit v1.2.3 From c22b5565114941ce5d62f64916fe713eb1141880 Mon Sep 17 00:00:00 2001 From: Cy Date: Mon, 30 Jun 2014 16:14:14 -0700 Subject: Improved stacking This stack / copy uses a direction vector, so it's not limited to only along the X/Y/Z axis, and can go diagonally. This enables things like building staircases. --- worldedit_commands/init.lua | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'worldedit_commands/init.lua') diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 04f2f4c..e7b0f74 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -619,6 +619,52 @@ minetest.register_chatcommand("/stack", { end), }) +minetest.register_chatcommand("/stack2", { + params = " //", + description = "Stack the current WorldEdit region times translating each time by x, y and z in the respective directions.", + 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, "Select a position first!") + return + end + local repetitions, incs = param:match("([0-9]+)%s*(.+)") + repetitions = repetitions and tonumber(repetitions) + if repetitions == nil then + worldedit.player_notify(name, "invalid count: " .. param) + return + end + + local x,y,z = incs:match("(.+)/(.+)/(.+)") + if x == nil then + worldedit.player_notify(name, "invalid increments: " .. param) + return + end + x = tonumber(x) + y = tonumber(y) + z = tonumber(z) + if x == nil or y == nil or z == nil then + worldedit.player_notify(name, "increments must be numbers: " .. param) + return + end + + local count = worldedit.volume(pos1,pos2) * repetitions + + return safe_region(function() + worldedit.stack2(pos1, pos2, {x=x,y=y,z=z}, repetitions, + function() + worldedit.player_notify(name, count .. " nodes stacked") + end) + + end, + function() + return count + end)(name,param) -- more hax + end +}) + + minetest.register_chatcommand("/stretch", { params = " ", description = "Scale the current WorldEdit positions and region by a factor of , , along the X, Y, and Z axes, repectively, with position 1 as the origin", -- cgit v1.2.3