[Solved] making orbs with voxel fails?
Im trying to make holes or orbs with voxel, because it seems to use significantly less cpu.
im checked how the tnt mod works, but are confused that the positions of the changed data always places or parts on wrong/randomly positions.
this does not happen if im using set_node
what is wrong?

im checked how the tnt mod works, but are confused that the positions of the changed data always places or parts on wrong/randomly positions.
this does not happen if im using set_node
what is wrong?
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_tool("tools:rad", {
description = "rad",
inventory_image = "default_stick.png",
groups={not_in_creative_inventory = 0,},
on_use = function(itemstack, user, pointed_thing)
local radius=5
local pos = user:getpos()
local pos1 = vector.subtract(pos, radius)
local pos2 = vector.add(pos, radius)
local vox = VoxelManip()
local min, max = vox:read_from_map(pos1, pos2)
local area = VoxelArea:new({MinEdge = min, MaxEdge = max})
local data = vox:get_data()
local air=minetest.get_content_id("air")
local dirt=minetest.get_content_id("default:dirt")
for z = -radius, radius do
for y = -radius, radius do
for x = -radius, radius do
local rad = vector.length(vector.new(x,y,z))
--local p={x=pos.x+x,y=pos.y+y,z=pos.z+z}
--local node=minetest.get_node(p)
local v = area:index(pos.x+x,pos.y+y,pos.z+z)
if radius/rad>=1 and data[v]==air then
--minetest.set_node(p,{name="air"})
data[v]=dirt
end
end
end
end
vox:set_data(data)
vox:write_to_map()
vox:update_map()
vox:update_liquids()
end
})