diff options
| author | Uberi <azhang9@gmail.com> | 2014-07-06 19:42:02 -0400 | 
|---|---|---|
| committer | Uberi <azhang9@gmail.com> | 2014-07-06 19:42:02 -0400 | 
| commit | 175ac211ca06af7eec9dfbc62e11e1d6eb448c03 (patch) | |
| tree | 37a75c6557cfd06672598f81f0998e921c101c13 /worldedit_commands | |
| parent | b32aadd7fafdaef8c6ab1dd578860717d144d4f9 (diff) | |
Documentation for `//stack2`, code style fixes, add author section to README.
Diffstat (limited to 'worldedit_commands')
| -rw-r--r-- | worldedit_commands/init.lua | 47 | 
1 files changed, 18 insertions, 29 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index e7b0f74..3fa9422 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -279,19 +279,18 @@ minetest.register_chatcommand("/volume", {  })
  minetest.register_chatcommand("/set", {
 -	params = "<node>",
 -	description = "Set the current WorldEdit region to <node>",
 +	params = "<node1> ...",
 +	description = "Set the current WorldEdit region to a random mix of <node1>, ...",
  	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..'"')
 +                worldedit.player_notify(name, "Could not identify node \"" .. name .. "\"")
                  return
              end
 -            nodes[#nodes+1] = node
 +            nodes[#nodes + 1] = node
          end
  		local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
 @@ -620,47 +619,37 @@ minetest.register_chatcommand("/stack", {  })
  minetest.register_chatcommand("/stack2", {
 -	params = "<count> <x>/<y>/<z>",
 -	description = "Stack the current WorldEdit region <count> times translating each time by x, y and z in the respective directions.",
 +	params = "<count> <x> <y> <z>",
 +	description = "Stack the current WorldEdit region <count> times by offset <x>, <y>, <z>",
  	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!")
 +			worldedit.player_notify(name, "Select a position first!")
              return
          end
 -        local repetitions, incs = param:match("([0-9]+)%s*(.+)")
 -        repetitions = repetitions and tonumber(repetitions)
 +        local repetitions, incs = param:match("(%d+)%s*(.+)")
          if repetitions == nil then
  			worldedit.player_notify(name, "invalid count: " .. param)
 -            return 
 +            return
          end
 +		repetitions = tonumber(repetitions)
 -        local x,y,z = incs:match("(.+)/(.+)/(.+)")
 +        local x, y, z = incs:match("([+-]?%d+) ([+-]%d+) ([+-]%d+)")
          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
 +        x, y, z = tonumber(x), tonumber(y), tonumber(z)
 -        local count = worldedit.volume(pos1,pos2) * repetitions
 +        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
 +			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
  })
  | 
