summaryrefslogtreecommitdiff
path: root/worldedit
diff options
context:
space:
mode:
authorWuzzy <wuzzy2@mail.ru>2017-09-05 14:40:46 +0200
committersfan5 <sfan5@live.de>2017-09-05 14:40:46 +0200
commit3c61759bae15d8bedc9c54b4e3903479a5f4cf08 (patch)
tree39927d87549c4ba02801e8f2e18576c4c8852edb /worldedit
parent2f4eb19a3afa73b95fd5ce50011c3292dec8bbc2 (diff)
Allow to bulk-set param2 of regions (#144)
Diffstat (limited to 'worldedit')
-rw-r--r--worldedit/manipulations.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/worldedit/manipulations.lua b/worldedit/manipulations.lua
index 57c7a76..995619c 100644
--- a/worldedit/manipulations.lua
+++ b/worldedit/manipulations.lua
@@ -38,6 +38,29 @@ function worldedit.set(pos1, pos2, node_names)
return worldedit.volume(pos1, pos2)
end
+--- Sets param2 of a region.
+-- @param pos1
+-- @param pos2
+-- @param param2 Value of param2 to set
+-- @return The number of nodes set.
+function worldedit.set_param2(pos1, pos2, param2)
+ pos1, pos2 = worldedit.sort_pos(pos1, pos2)
+
+ local manip, area = mh.init(pos1, pos2)
+ local param2_data = manip:get_param2_data()
+
+ -- Set param2 for every node
+ for i in area:iterp(pos1, pos2) do
+ param2_data[i] = param2
+ end
+
+ -- Update map
+ manip:set_param2_data(param2_data)
+ manip:write_to_map()
+ manip:update_map()
+
+ return worldedit.volume(pos1, pos2)
+end
--- Replaces all instances of `search_node` with `replace_node` in a region.
-- When `inverse` is `true`, replaces all instances that are NOT `search_node`.