diff options
| author | Cy <whatever> | 2014-06-30 16:13:44 -0700 | 
|---|---|---|
| committer | Cy <whatever> | 2014-06-30 16:13:44 -0700 | 
| commit | 174416b010cd7833edb12f7ec7db7ab8f1918bce (patch) | |
| tree | 03966da54a96475aa95da8af83616d90a17f3b2d /worldedit_commands | |
| parent | 2c4a79180503adfdb0ba6c4b0f893ebb16521bd3 (diff) | |
Randomized set
Can /set node node2 node3 and it will randomly choose between those
three.
Diffstat (limited to 'worldedit_commands')
| -rw-r--r-- | worldedit_commands/init.lua | 22 | 
1 files changed, 13 insertions, 9 deletions
| 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 = "<node>",
  	description = "Set the current WorldEdit region to <node>",
  	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)
 | 
