pass a heightmap to mapgen.

Post Reply
Ghurir
Member
Posts: 12
Joined: Mon Jan 30, 2023 17:30

pass a heightmap to mapgen.

by Ghurir » Post

I want to use a custom heightmap, on top of which the normal generation would happen.
I have looked online, but I am overwhelmed by the different methods. It seems to me that some questions are outdated, and new methods for modifying the map generation have been added. That's why I would appreciate your advice on how to go about this.

Ghurir
Member
Posts: 12
Joined: Mon Jan 30, 2023 17:30

Re: pass a heightmap to mapgen.

by Ghurir » Post

I figured to use a single-node world, do my own terrain generation, and then call core.generate_decorations
See below an example:

Code: Select all

core.register_on_generated(function(minp, maxp, seed)
    local vm, emin, emax = core.get_mapgen_object("voxelmanip")
    local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
    local data = vm:get_data()

    for z = minp.z, maxp.z do
        for x = minp.x, maxp.x do
            local h = get_height(x, z)
            for y = minp.y, maxp.y do
                local vi = area:index(x,y,z)

                data[vi] = stone
                if y > h then
                    data[vi] = air
                elseif y == h then
                    data[vi] = grass
                elseif y > h - 3 then
                    data[vi] = dirt 
                end
                end
            end
        end
    end

    vm:set_data(data)

    -- generate decoration and ores
    -- core.generate_ores(vm, minp, maxp)
    core.generate_decorations(vm, minp, maxp)
    
	-- Calculate lighting, write data, and update liquids
	vm:calc_lighting()
	vm:write_to_map()
	vm:update_liquids()
end)

Opons
Member
Posts: 44
Joined: Thu Nov 17, 2022 04:20
IRC: Opons
In-game: Opons

Re: pass a heightmap to mapgen.

by Opons » Post

This mod may be with trying at as well: https://content.luanti.org/packages/Gae ... /biomegen/
yes

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests