1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Add core.spawn_tree_on_vmanip (#15415)

This function works like `core.spawn_tree`, but spawns an L-system tree onto a VoxelManip object instead on the map.
This commit is contained in:
cx384 2024-12-08 20:27:22 +01:00 committed by GitHub
parent 8d43ad2522
commit c7fe2ee5c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 110 additions and 10 deletions

View file

@ -1773,6 +1773,27 @@ int ModApiMapgen::l_place_schematic_on_vmanip(lua_State *L)
return 1;
}
// spawn_tree_on_vmanip(vmanip, pos, treedef)
int ModApiMapgen::l_spawn_tree_on_vmanip(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
MMVManip *vm = checkObject<LuaVoxelManip>(L, 1)->vm;
v3s16 p0 = read_v3s16(L, 2);
treegen::TreeDef tree_def;
const NodeDefManager *ndef = getGameDef(L)->ndef();
if (!read_tree_def(L, 3, ndef, tree_def))
return 0;
treegen::error e = treegen::make_ltree(*vm, p0, tree_def);
if (e != treegen::SUCCESS) {
throw LuaError("spawn_tree_on_vmanip(): " + treegen::error_to_string(e));
}
lua_pushboolean(L, true);
return 1;
}
// serialize_schematic(schematic, format, options={...})
int ModApiMapgen::l_serialize_schematic(lua_State *L)
@ -2023,6 +2044,7 @@ void ModApiMapgen::Initialize(lua_State *L, int top)
API_FCT(create_schematic);
API_FCT(place_schematic);
API_FCT(place_schematic_on_vmanip);
API_FCT(spawn_tree_on_vmanip);
API_FCT(serialize_schematic);
API_FCT(read_schematic);
}
@ -2049,6 +2071,7 @@ void ModApiMapgen::InitializeEmerge(lua_State *L, int top)
API_FCT(generate_ores);
API_FCT(generate_decorations);
API_FCT(place_schematic_on_vmanip);
API_FCT(spawn_tree_on_vmanip);
API_FCT(serialize_schematic);
API_FCT(read_schematic);
}