summaryrefslogtreecommitdiff
path: root/worldedit/manipulations.lua
diff options
context:
space:
mode:
authorCy <whatever>2014-06-30 16:13:44 -0700
committerCy <whatever>2014-06-30 16:13:44 -0700
commit174416b010cd7833edb12f7ec7db7ab8f1918bce (patch)
tree03966da54a96475aa95da8af83616d90a17f3b2d /worldedit/manipulations.lua
parent2c4a79180503adfdb0ba6c4b0f893ebb16521bd3 (diff)
Randomized set
Can /set node node2 node3 and it will randomly choose between those three.
Diffstat (limited to 'worldedit/manipulations.lua')
-rw-r--r--worldedit/manipulations.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/worldedit/manipulations.lua b/worldedit/manipulations.lua
index 1d4c6dc..40915ed 100644
--- a/worldedit/manipulations.lua
+++ b/worldedit/manipulations.lua
@@ -24,7 +24,11 @@ worldedit.volume = function(pos1, pos2)
end
--sets a region defined by positions `pos1` and `pos2` to `nodename`, returning the number of nodes filled
-worldedit.set = function(pos1, pos2, nodename)
+worldedit.set = function(pos1, pos2, nodenames)
+ if type(nodenames) == 'string' then
+ nodenames = {nodenames}
+ end
+
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
--set up voxel manipulator
@@ -40,9 +44,12 @@ worldedit.set = function(pos1, pos2, nodename)
end
--fill selected area with node
- local node_id = minetest.get_content_id(nodename)
+ local node_ids = {}
+ for i,v in ipairs(nodenames) do
+ node_ids[i] = minetest.get_content_id(nodenames[i])
+ end
for i in area:iterp(pos1, pos2) do
- nodes[i] = node_id
+ nodes[i] = node_ids[math.random(#node_ids)]
end
--update map nodes