Not bad neuromancer, though i had already made a few changes/optimisations to spheres (spawn much faster):
Code: Select all
-------------------------------------------------------
-------------- SPHERES & HOLLOW SPHERES ---------------------------
---------------------------------------------------------------
local SPHERE_SIZE = 12
local POINT_ZERO = nil
local HOLLOW_THICKNESS = 1
local function sphere(pos,nodename)
pos.x = math.floor(pos.x+0.5)
pos.y = math.floor(pos.y+0.5)
pos.z = math.floor(pos.z+0.5)
--[[ local operations = SPHERE_SIZE + SPHERE_SIZE
operations = operations * operations * operations
print(operations..' node operations')
local count = 0 ]]--
for x=-SPHERE_SIZE,SPHERE_SIZE do
for y=-SPHERE_SIZE,SPHERE_SIZE do
for z=-SPHERE_SIZE,SPHERE_SIZE do
if x*x+y*y+z*z <= SPHERE_SIZE * SPHERE_SIZE + SPHERE_SIZE then
minetest.env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z},{type="node",name=nodename})
-- count = count + 1
-- print(math.floor(((count/operations)*100)+0.5)..'% complete')
end
end
end
end
end
local function hsphere(pos,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)
--[[ local operations = SPHERE_SIZE + SPHERE_SIZE
operations = operations * operations * operations
print(operations..' node operations')
local count = 0 ]]--
for x=-SPHERE_SIZE,SPHERE_SIZE do
for y=-SPHERE_SIZE,SPHERE_SIZE do
for z=-SPHERE_SIZE,SPHERE_SIZE do
if x*x+y*y+z*z >= (SPHERE_SIZE-hollow) * (SPHERE_SIZE-hollow) + (SPHERE_SIZE-hollow) and x*x+y*y+z*z <= SPHERE_SIZE * SPHERE_SIZE + SPHERE_SIZE then
minetest.env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z},{type="node",name=nodename})
-- count = count + 1
-- print(math.floor(((count/operations)*100)+0.5)..'% complete')
end
end
end
end
end
minetest.register_chatcommand("p0", {
params = "<none>",
description = "spawn a sphere",
privs = {server=true},
func = function(name, param)
POINT_ZERO = minetest.env:get_player_by_name(name):getpos()
minetest.chat_send_player(name, "p0 set")
end, })
minetest.register_chatcommand("radius", {
params = "<radius>",
description = "set radius of sphere, default 12",
privs = {server=true},
func = function(name, param)
SPHERE_SIZE = param
minetest.chat_send_player(name, "radius set")
end, })
minetest.register_chatcommand("sphere", {
params = "<nodename>",
description = "spawn a sphere",
privs = {server=true},
func = function(name, param)
if POINT_ZERO == nil then minetest.chat_send_player(name, "there is no p0 only zuul") return end
minetest.chat_send_player(name, "spawning...larger spheres = more time, may need to retry if partial spawn")
sphere(POINT_ZERO, param)
end, })
minetest.register_chatcommand("thickness", {
params = "<hollow sphere thickness>",
description = "set thickness of hollow spheres, default 1",
privs = {server=true},
func = function(name, param)
HOLLOW_THICKNESS = param
minetest.chat_send_player(name, "thickness set")
end, })
minetest.register_chatcommand("hollowsphere", {
params = "<nodename>",
description = "spawn a hollow sphere",
privs = {server=true},
func = function(name, param)
if POINT_ZERO == nil then minetest.chat_send_player(name, "there is no p0 only zuul") return end
minetest.chat_send_player(name, "spawning...larger spheres = more time, may need to retry if partial spawn")
hsphere(POINT_ZERO, param, HOLLOW_THICKNESS)
end, })
Ill add the cylinders (and saucers) for the next release :-) Ill credit you in the OP for multinode - and multinode will likely be part of default mods for Nullspace :-)
@Temperest
mine is almost the same format, except i dont save param2 or node metadata, and instead of spaces i use special characters. The only thing i need to mull over is weather to write import/export functions or simply convert my format. Though i need to know if there are any strings/licensing issues attached to using WE formats? (i doubt it but w/ my luck id rather be safe than sorry lol)