Improvements to the pretty-printer

This commit is contained in:
2021-11-26 12:28:59 -05:00
parent 63bca62edd
commit c02109699e
7 changed files with 75 additions and 52 deletions

View File

@@ -127,7 +127,7 @@ World::TanVector World::tangible_get_all(const IdVector &ids) const {
}
Tangible *World::tangible_get(const LuaStack &LS, LuaSlot tab) {
int64_t id = tangible_id(LS, tab);
int64_t id = LS.tanid(tab);
if (id == 0) {
luaL_error(LS.state(), "parameter is not a tangible");
}
@@ -138,22 +138,6 @@ Tangible *World::tangible_get(const LuaStack &LS, LuaSlot tab) {
return result;
}
int64_t World::tangible_id(const LuaStack &LS, LuaSlot tab) {
int64_t id = 0;
if (LS.istable(tab) && LS.gettabletype(tab) == LUA_TT_TANGIBLE) {
lua_State *L = LS.state();
if (lua_getmetatable(L, tab.index())) {
lua_pushstring(L, "id");
lua_rawget(L, -2);
if (lua_type(L, -1) == LUA_TNUMBER) {
id = lua_tointeger(L, -1);
}
lua_pop(L, 2);
}
}
return id;
}
Tangible *World::tangible_make(lua_State *L, int64_t id, const std::string &plane, bool pushdb) {
// Get a state if we don't already have one.
if (L == nullptr) {