diff options
author | Jude Melton-Houghton <jwmhjwmh@gmail.com> | 2022-11-23 11:53:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-23 11:53:21 -0500 |
commit | 386bfcda2b3565b38c79af76743ad3d76c452fd5 (patch) | |
tree | 4d4ce223444852a740493ee28abaef330ec56d18 /src/script | |
parent | 4da8a18c8c72a125a3ea4f3842e08757d8dbe321 (diff) | |
download | minetest-386bfcda2b3565b38c79af76743ad3d76c452fd5.tar.xz |
Fix reading schematics after their resolution (#12985)
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 6c345c4ed..1e4197df3 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -1694,6 +1694,7 @@ int ModApiMapgen::l_read_schematic(lua_State *L) const SchematicManager *schemmgr = getServer(L)->getEmergeManager()->getSchematicManager(); + const NodeDefManager *ndef = getGameDef(L)->ndef(); //// Read options std::string write_yslice = getstringfield_default(L, 2, "write_yslice_prob", "all"); @@ -1713,6 +1714,7 @@ int ModApiMapgen::l_read_schematic(lua_State *L) //// Create the Lua table u32 numnodes = schem->size.X * schem->size.Y * schem->size.Z; + bool resolve_done = schem->isResolveDone(); const std::vector<std::string> &names = schem->m_nodenames; lua_createtable(L, 0, (write_yslice == "none") ? 2 : 3); @@ -1742,10 +1744,12 @@ int ModApiMapgen::l_read_schematic(lua_State *L) lua_createtable(L, numnodes, 0); // data table for (u32 i = 0; i < numnodes; ++i) { MapNode node = schem->schemdata[i]; + const std::string &name = + resolve_done ? ndef->get(node.getContent()).name : names[node.getContent()]; u8 probability = node.param1 & MTSCHEM_PROB_MASK; bool force_place = node.param1 & MTSCHEM_FORCE_PLACE; lua_createtable(L, 0, force_place ? 4 : 3); - lua_pushstring(L, names[schem->schemdata[i].getContent()].c_str()); + lua_pushstring(L, name.c_str()); lua_setfield(L, 3, "name"); lua_pushinteger(L, probability * 2); lua_setfield(L, 3, "prob"); |