//set Blue Lightstone\r
//set dirt with grass\r
\r
+### `//param2 <param2>`\r
+\r
+Set the param2 value of all nodes in the current WorldEdit region to `<param2>`.\r
+\r
### `//mix <node1> ...`\r
\r
Fill the current WorldEdit region with a random mix of `<node1>`, `...`.\r
\r
Returns the number of nodes set.\r
\r
+### `count = worldedit.set_param2(pos1, pos2, param2)`\r
+\r
+Sets the param2 values of all nodes in a region defined by positions `pos1` and `pos2` to `param2`.\r
+\r
+Returns the number of nodes set.\r
+\r
### count = worldedit.replace(pos1, pos2, searchnode, replacenode)\r
\r
Replaces all instances of `searchnode` with `replacenode` in a region defined by positions `pos1` and `pos2`.\r
return worldedit.volume(pos1, pos2)\r
end\r
\r
+--- Sets param2 of a region.\r
+-- @param pos1\r
+-- @param pos2\r
+-- @param param2 Value of param2 to set\r
+-- @return The number of nodes set.\r
+function worldedit.set_param2(pos1, pos2, param2)\r
+ pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
+\r
+ local manip, area = mh.init(pos1, pos2)\r
+ local param2_data = manip:get_param2_data()\r
+\r
+ -- Set param2 for every node\r
+ for i in area:iterp(pos1, pos2) do\r
+ param2_data[i] = param2\r
+ end\r
+\r
+ -- Update map\r
+ manip:set_param2_data(param2_data)\r
+ manip:write_to_map()\r
+ manip:update_map()\r
+\r
+ return worldedit.volume(pos1, pos2)\r
+end\r
\r
--- Replaces all instances of `search_node` with `replace_node` in a region.\r
-- When `inverse` is `true`, replaces all instances that are NOT `search_node`.\r
end, check_region),\r
})\r
\r
+minetest.register_chatcommand("/param2", {\r
+ params = "<param2>",\r
+ description = "Set param2 of all nodes in the current WorldEdit region to <param2>",\r
+ privs = {worldedit=true},\r
+ func = safe_region(function(name, param)\r
+ local param2 = tonumber(param)\r
+ if not param2 then\r
+ worldedit.player_notify(name, "Invalid or missing param2 argument")\r
+ return\r
+ elseif param2 < 0 or param2 > 255 then\r
+ worldedit.player_notify(name, "Param2 is out of range (must be between 0 and 255 inclusive)!")\r
+ return\r
+ end\r
+\r
+ local count = worldedit.set_param2(worldedit.pos1[name], worldedit.pos2[name], param2)\r
+ worldedit.player_notify(name, count .. " nodes altered")\r
+ end, check_region),\r
+})\r
+\r
minetest.register_chatcommand("/mix", {\r
params = "<node1> ...",\r
description = "Fill the current WorldEdit region with a random mix of <node1>, ...",\r