Why doesn't fill this code the air?

Post Reply
User avatar
burli
Member
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Why doesn't fill this code the air?

by burli » Post

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

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)
Image
Attachments
screenshot_20170216_194749.jpg
(706.5 KiB) Not downloaded yet

User avatar
paramat
Developer
Posts: 3691
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: Why doesn't fill this code the air?

by paramat » Post

Now solved.

User avatar
rubenwardy
Moderator
Posts: 6278
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: Why doesn't fill this code the air?

by rubenwardy » Post

For reference
paramat wrote:Try local a = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
The voxelarea is always set to emin, emax which is the minimum volume of complete mapblocks that contains the requested volume.
With the mapgen object voxelmanip, although the mapchunk is minp to maxp 5^3 mapblocks, the actual processed volume is that plus a 1-mapblock deep shell of mapblocks (that overlap with other mapchunks), so 7^3 mapblocks.
https://github.com/minetest/minetest/issues/5254

User avatar
burli
Member
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Why doesn't fill this code the air?

by burli » Post

Thanks. Had no time to update here

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests