diff options
Diffstat (limited to 'functions.lua')
-rw-r--r-- | functions.lua | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/functions.lua b/functions.lua index 270b50e..ee549de 100644 --- a/functions.lua +++ b/functions.lua @@ -1,3 +1,4 @@ +dofile(minetest.get_modpath("worldedit") .. "/spirals.lua")
--modifies positions `pos1` and `pos2` so that each component of `pos1` is less than or equal to its corresponding conent of `pos2`, returning two new positions
worldedit.sort_pos = function(pos1, pos2)
pos1 = {x=pos1.x, y=pos1.y, z=pos1.z}
@@ -182,6 +183,26 @@ worldedit.cylinder = function(pos, axis, length, radius, nodename) return count
end
+--adds a spiral at `pos` with size `size`, returning the number of nodes changed
+worldedit.spiral = function(pos, size, nodename)
+ local shift_x,shift_y
+ sa = spiralt(size)
+ shift_y = #sa -- "Height" of the Array
+ local fe = sa[1]
+ shift_x = #fe -- "Width" of the Array
+ fe = nil
+
+ local count = 0
+ for x,v in ipairs(sa) do
+ for y, z in ipairs(v) do
+ minetest.env:add_node({x=pos.x-shift_x+x,y=pos.y-shift_y+y,z=pos.z+z}, {name=nodename})
+ count = count + 1
+ end
+ end
+
+ return count
+end
+
--copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes, returning the number of nodes copied
worldedit.copy = function(pos1, pos2, axis, amount)
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
@@ -476,4 +497,4 @@ worldedit.deserialize_old = function(originpos, value) count = count + 1
end
return count
-end
\ No newline at end of file +end
|