summaryrefslogtreecommitdiff
path: root/worldedit_commands/init.lua
diff options
context:
space:
mode:
authorStarbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>2018-10-12 21:06:01 +0100
committersfan5 <sfan5@live.de>2018-10-29 00:36:33 +0100
commitb37605943bd384cc1809df7f00740cbe1e266111 (patch)
tree196c0c67a632e67ebe4d1e7cfab388a720b804ca /worldedit_commands/init.lua
parentf7256633c03f2bc60288271dbd17ef4ed31256ae (diff)
//mix: Add node weighting support
Diffstat (limited to 'worldedit_commands/init.lua')
-rw-r--r--worldedit_commands/init.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua
index 3640e0d..131c49b 100644
--- a/worldedit_commands/init.lua
+++ b/worldedit_commands/init.lua
@@ -425,15 +425,22 @@ minetest.register_chatcommand("/param2", {
})
minetest.register_chatcommand("/mix", {
- params = "<node1> ...",
+ params = "<node1> [<weighting1>] [<node2> [<weighting2>]] ...",
description = "Fill the current WorldEdit region with 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 return end
- nodes[#nodes + 1] = node
+ if tonumber(nodename) ~= nil and #nodes > 0 then
+ local last_node = nodes[#nodes]
+ for i = 1, tonumber(nodename) do
+ nodes[#nodes + 1] = last_node
+ end
+ else
+ local node = get_node(name, nodename)
+ if not node then return end
+ nodes[#nodes + 1] = node
+ end
end
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]