diff options
Diffstat (limited to 'src/script/lua_api/l_nodemeta.cpp')
-rw-r--r-- | src/script/lua_api/l_nodemeta.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/script/lua_api/l_nodemeta.cpp b/src/script/lua_api/l_nodemeta.cpp index 906cc3172..6cdbe5c68 100644 --- a/src/script/lua_api/l_nodemeta.cpp +++ b/src/script/lua_api/l_nodemeta.cpp @@ -190,32 +190,34 @@ int NodeMetaRef::l_to_table(lua_State *L) NodeMetaRef *ref = checkobject(L, 1); NodeMetadata *meta = getmeta(ref, true); - if(meta == NULL){ + if (meta == NULL) { lua_pushnil(L); return 1; } lua_newtable(L); + // fields lua_newtable(L); { - std::map<std::string, std::string> fields = meta->getStrings(); - for(std::map<std::string, std::string>::const_iterator - i = fields.begin(); i != fields.end(); i++){ - const std::string &name = i->first; - const std::string &value = i->second; + StringMap fields = meta->getStrings(); + for (StringMap::const_iterator + it = fields.begin(); it != fields.end(); ++it) { + const std::string &name = it->first; + const std::string &value = it->second; lua_pushlstring(L, name.c_str(), name.size()); lua_pushlstring(L, value.c_str(), value.size()); lua_settable(L, -3); } } lua_setfield(L, -2, "fields"); + // inventory lua_newtable(L); Inventory *inv = meta->getInventory(); - if(inv){ - std::vector<const InventoryList*> lists = inv->getLists(); - for(std::vector<const InventoryList*>::const_iterator - i = lists.begin(); i != lists.end(); i++){ + if (inv) { + std::vector<const InventoryList *> lists = inv->getLists(); + for(std::vector<const InventoryList *>::const_iterator + i = lists.begin(); i != lists.end(); i++) { push_inventory_list(L, inv, (*i)->getName().c_str()); lua_setfield(L, -2, (*i)->getName().c_str()); } |