Created
October 2, 2012 12:44
-
-
Save cornernote/3818782 to your computer and use it in GitHub Desktop.
Generate a Sphere (based on sphere in multinode by mauvebic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generate_sphere = function(pos,radius,nodename,hollow) | |
pos.x = math.floor(pos.x+0.5) | |
pos.y = math.floor(pos.y+0.5) | |
pos.z = math.floor(pos.z+0.5) | |
for x=-radius,radius do | |
for y=-radius,radius do | |
for z=-radius,radius do | |
if hollow ~= nil then | |
if x*x+y*y+z*z >= (radius-hollow) * (radius-hollow) + (radius-hollow) and x*x+y*y+z*z <= radius * radius + radius then | |
minetest.env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z},{name=nodename}) | |
end | |
else | |
if x*x+y*y+z*z <= radius * radius + radius then | |
minetest.env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z},{name=nodename}) | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment