[Mod][Library] Biome generator for Lua mapgens [biomegen]

Post Reply
User avatar
Gael de Sailly
Member
Posts: 774
Joined: Sun Jan 26, 2014 17:01
GitHub: Gael-de-Sailly
IRC: Gael-de-Sailly
In-game: Gael-de-Sailly Ginkgoo
Location: France

[Mod][Library] Biome generator for Lua mapgens [biomegen]

by Gael de Sailly » Post

Hello,

This mod aims at re-implementing core biome system (biomes, decorations and dust) for Lua mapgens. It is a library (it does not do anything standalone), providing functions intended to be used in Lua mapgen mods, at the end of mapgen loop.

It reads biomes and decorations registered by minetest.register_biome and minetest.register_decoration, so it is natively compatible with minetest_game and all mods/games using these functions to add content.

It applies to mapgens that generate only stone, water, river water and air, and requires to add biomegen as a dependency (mandatory or optional) of the mapgen mod.

Image
^ biomegen used by a Lua mapgen, under vanilla Minetest Game

The main function is biomegen.generate_all(data, area, vm, minp, maxp, seed), to be added after mapgen loop, but before writing vm to map. It generates biomes, decorations, ores and dust (for now using core function for ores). Other function do these steps separately, check Readme for more details.

Example:

Code: Select all

local data = {}

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

	------------------------
	-- [MAPGEN LOOP HERE] --
	------------------------

	-- Generate biomes, decorations, ores and dust
	biomegen.generate_all(data, area, vm, minp, maxp, seed)

	-- Calculate lighting for what has been created.
	vm:calc_lighting()
	-- Write what has been created to the world.
	vm:write_to_map()
	-- Liquid nodes were placed so set them flowing.
	vm:update_liquids()
end)
Example mod to see it in action: lvm_example-biomegen (modified version of Paramat's lvm_example). The screenshot comes from it.

Download zip / Browse the code
Just realize how bored we would be if the world was perfect.

Post Reply

Who is online

Users browsing this forum: Google [Bot], sirrobzeroone and 6 guests