]> git.lizzy.rs Git - worldedit.git/commitdiff
worldedit.hollow_sphere returns non-nil count
authorKyle <kyle.kylina@gmail.com>
Wed, 17 Oct 2012 23:18:19 +0000 (16:18 -0700)
committerKyle <kyle.kylina@gmail.com>
Wed, 17 Oct 2012 23:18:19 +0000 (16:18 -0700)
worldedit/primitives.lua

index 2685d2bbbfe8ad098c3551c82edaee0694156724..37e2298a408adfe800b89827f506c159967a7772 100644 (file)
@@ -5,6 +5,7 @@ worldedit.hollow_sphere = function(pos, radius, nodename) --wip: use bresenham s
        local node = {name=nodename}\r
        local pos1 = {x=0, y=0, z=0}\r
        local full_radius = radius * radius + radius\r
+       local count = 0\r
        local env = minetest.env\r
        for x = -radius, radius do\r
                pos1.x = pos.x + x\r
@@ -14,10 +15,12 @@ worldedit.hollow_sphere = function(pos, radius, nodename) --wip: use bresenham s
                                if x*x+y*y+z*z >= (radius-1) * (radius-1) + (radius-1) and x*x+y*y+z*z <= full_radius then\r
                                        pos1.z = pos.z + z\r
                                        env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z}, node)\r
+                                       count = count + 1\r
                                end\r
                        end\r
                end\r
        end\r
+       return count\r
 end\r
 \r
 --adds a sphere at `pos` with radius `radius`, composed of `nodename`, returning the number of nodes added\r