Skip to content

Instantly share code, notes, and snippets.

@cornernote
Created October 2, 2012 12:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cornernote/3818782 to your computer and use it in GitHub Desktop.
Save cornernote/3818782 to your computer and use it in GitHub Desktop.
Generate a Sphere (based on sphere in multinode by mauvebic)
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