Why doesn't fill this code the air?
Posted: Thu Feb 16, 2017 19:05
I want to find air in a map. To test my code I replace air with meselamp. But it doesn't fill everything. The gap is 39 nodes wide, the filled area 41 nodes
Edit: it also happens if I remove the if statement and try to overwrite each node
Edit: it also happens if I remove the if statement and try to overwrite each node
Code: Select all
minetest.register_on_generated(function(minp, maxp)
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
local c_air = minetest.get_content_id("air")
local c_glass = minetest.get_content_id("default:meselamp")
for z = minp.z, maxp.z do
for y = minp.y, maxp.y do
for x = minp.x, maxp.x do
local vi = a:index(x, y, z)
if data[vi] == c_air then
data[vi] = c_glass
end
end
end
end
vm:set_data(data)
vm:write_to_map()
end)