]> git.lizzy.rs Git - worldedit.git/commitdiff
//mix: Add node weighting support
authorStarbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Fri, 12 Oct 2018 20:06:01 +0000 (21:06 +0100)
committersfan5 <sfan5@live.de>
Sun, 28 Oct 2018 23:36:33 +0000 (00:36 +0100)
ChatCommands.md
worldedit_commands/init.lua

index a37b65a8105279fe629275d8faa2b75ea32757c5..ea1f9557309564d05ece86b4472846fff8d6691a 100644 (file)
@@ -121,14 +121,16 @@ Set the current WorldEdit region to `<node>`.
 \r
 Set the param2 value of all nodes in the current WorldEdit region to `<param2>`.\r
 \r
-### `//mix <node1> ...`\r
+### `//mix <node1> [<count1>] <node2> [<count2>]...`\r
 \r
-Fill the current WorldEdit region with a random mix of `<node1>`, `...`.\r
+Fill the current WorldEdit region with a random mix of `<node1>`, `<node2>`, `...`. Weightings can be optionally specified via a number after a node name.\r
 \r
     //mix air\r
     //mix cactus stone glass sandstone\r
     //mix Bronze\r
     //mix default:cobble air\r
+    //mix stone 3 dirt 2\r
+    //mix cobblestone 8 stoneblock 2 stonebrick\r
 \r
 ### `//replace <search node> <replace node>`\r
 \r
index 3640e0db99f04f62f5108ccd4f11f15b9b95600e..131c49b8509b646934eeb3490eae6fec1fb6395e 100644 (file)
@@ -425,15 +425,22 @@ minetest.register_chatcommand("/param2", {
 })\r
 \r
 minetest.register_chatcommand("/mix", {\r
-       params = "<node1> ...",\r
+       params = "<node1> [<weighting1>] [<node2> [<weighting2>]] ...",\r
        description = "Fill the current WorldEdit region with a random mix of <node1>, ...",\r
        privs = {worldedit=true},\r
        func = safe_region(function(name, param)\r
                local nodes = {}\r
                for nodename in param:gmatch("[^%s]+") do\r
-                       local node = get_node(name, nodename)\r
-                       if not node then return end\r
-                       nodes[#nodes + 1] = node\r
+                       if tonumber(nodename) ~= nil and #nodes > 0 then\r
+                               local last_node = nodes[#nodes]\r
+                               for i = 1, tonumber(nodename) do\r
+                                       nodes[#nodes + 1] = last_node\r
+                               end\r
+                       else\r
+                               local node = get_node(name, nodename)\r
+                               if not node then return end\r
+                               nodes[#nodes + 1] = node\r
+                       end\r
                end\r
 \r
                local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]\r