MAPGEN generation problem

Post Reply
Sporax
Member
Posts: 147
Joined: Mon Jul 11, 2016 16:33
GitHub: Sporax
IRC: Sporax
In-game: Sporax
Location: France

MAPGEN generation problem

by Sporax » Post

Hi guys!

I'm creating a mod that add a lava underground to minetest. At -30912 (map limit) there is 2 lava_source block and no stone anymore since -30800. I did it with minetest function: minetest.register_on_generated(function(minp, maxp)

However, i'l like to add some decoration with minetest function: minetest.register_decoration(). But nothing appears... here is my code. If someone can help me to find the problem... It may be that a function is called after another one ?

Code: Select all

local path = minetest.get_modpath("lavaground")
 
local c_air = minetest.get_content_id("air")
local c_stone = minetest.get_content_id("default:stone")
local c_gravel = minetest.get_content_id("default:gravel")
local c_silver_sand = minetest.get_content_id("default:silver_sand")
local c_iron = minetest.get_content_id("default:stone_with_iron")
local c_copper = minetest.get_content_id("default:stone_with_copper")
local c_gold = minetest.get_content_id("default:stone_with_gold")
local c_diamond = minetest.get_content_id("default:stone_with_diamond")
local c_mese = minetest.get_content_id("default:stone_with_mese")
local c_meseblock = minetest.get_content_id("default:mese")
local c_glass = minetest.get_content_id("default:glass")

local lavaground_biomes = {
	"icesheet_under",
	"tundra_under",
	"taiga_under",
	"snowy_grassland_under",
	"grassland_under",
	"coniferous_forest_under",
	"deciduous_forest_under",
	"desert_under",
	"sandstone_desert_under",
	"cold_desert_under",
	"savanna_under",
	"rainforest_under"
}

minetest.register_on_generated(function(minp, maxp)
	if minp.y > -30800 then
		return
	end
 
	local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
	local data = vm:get_data()
	local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
 
	for i in area:iter(
		minp.x, minp.y, minp.z,
		maxp.x, math.min(maxp.y, -30800), maxp.z
	) do
		if data[i] ~= c_glass then
			data[i] = c_air
		end
	end

	vm:set_data(data)
	vm:set_lighting{day=0, night=0}
	vm:write_to_map()
end)

local lava_depth = -30912
local lava_height = 1

minetest.register_on_generated(function(minp, maxp)

	if minp.y > lava_depth + lava_height or maxp.y < lava_depth then
		return
	end

	local vm, mine, maxe = minetest.get_mapgen_object("voxelmanip")
	local area = VoxelArea:new({MinEdge=mine, MaxEdge=maxe})
	local data = vm:get_data()

	local random = math.random

	local c_lava = minetest.get_content_id("default:lava_source")

	local highest = math.min(lava_depth + lava_height, maxe.y)
	local lowest = math.max(lava_depth, mine.y)


	for y = lowest, highest do
		for x = mine.x, maxe.x do
			for z = mine.z, maxe.z do
				if random(0, y - lava_depth) == 0 then
					data[area:index(x, y, z)] = c_lava
				end
			end
		end
	end

	vm:set_data(data)
	vm:set_lighting{day=0, night=0}
	vm:write_to_map()

end)

minetest.register_decoration({
    deco_type = "schematic",
    place_on = "default:lava_source",
    sidelen = 16,
    fill_ratio = 0.002,
    biomes = lavaground_biomes,
    y_max = -31000,
    y_min = -30000,
    schematic = path.."/schematics/lava_peak4.mts",
    flags = "place_center_x, place_center_z",
    rotation = "random",
})





Thanks !

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests