From 48c9688da61ceea694e9e33efd0e1c03158d0c9e Mon Sep 17 00:00:00 2001 From: ROllerozxa Date: Sat, 12 Aug 2023 14:19:43 +0000 Subject: [PATCH] Custom Lua Mapgen: edit --- pages/Custom_Lua_Mapgen.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 pages/Custom_Lua_Mapgen.md diff --git a/pages/Custom_Lua_Mapgen.md b/pages/Custom_Lua_Mapgen.md new file mode 100644 index 0000000..02bf51a --- /dev/null +++ b/pages/Custom_Lua_Mapgen.md @@ -0,0 +1,16 @@ +The Minetest engine provides several built-in mapgens implemented in C++, where biomes and decorations can be registered by mods. In addition to this you can also write your own mapgen in Lua. Usually this is done by hooking into the `singlenode` mapgen (by default consisting only of void) and generating your own terrain in the `on_generated` callback using VoxelManip. + +## Performance +While it is possible to write very performant Lua mapgens, it will always generally be slower compared to C++ mapgens that run in their own thread and don't block the Lua thread. (This will be fixed once [#13092](https://github.com/minetest/minetest/pull/13092) is merged) + +For a list of optimisation techniques you can use to write performant mapgens, see [[Mapgen Optimisations]]. + +## Examples +A good initial example of how to write a custom Lua mapgen is paramat's [lvm_example](https://github.com/paramat/lvm_example/blob/master/init.lua). It incorporates most optimisations techniques to create a performant mapgen and uses Perlin noise to generate random looking terrain. + +For more examples of custom Lua mapgens, see the [Custom mapgen](https://content.minetest.net/packages/?type=mod&page=1&tag=custom_mapgen) tag on ContentDB. + +## Libraries +- [Luamap](https://content.minetest.net/packages/MisterE/luamap/) is a library that seeks to take out some of the pain of making custom mapgens by abstracting it away. + +- [Biomegen](https://content.minetest.net/packages/Gael%20de%20Sailly/biomegen/) reimplements the biome system used in built-in C++ mapgens for use with custom Lua mapgens. \ No newline at end of file