Fix minetest.get_inventory(loc) always returning nil for "node" type loc

master
MetaDucky 2013-05-26 11:27:06 +02:00 committed by Kahrl
parent a61aa6690b
commit 64627817fc
1 changed files with 13 additions and 17 deletions

View File

@ -416,9 +416,18 @@ int ModApiInventory::l_get_inventory(lua_State *L)
std::string type = checkstringfield(L, 1, "type"); std::string type = checkstringfield(L, 1, "type");
if(type != "pos"){ if(type == "node"){
NO_MAP_LOCK_REQUIRED; lua_getfield(L, 1, "pos");
v3s16 pos = check_v3s16(L, -1);
loc.setNodeMeta(pos);
if(getServer(L)->getInventory(loc) != NULL)
InvRef::create(L, loc);
else
lua_pushnil(L);
return 1;
} else {
NO_MAP_LOCK_REQUIRED;
if(type == "player"){ if(type == "player"){
std::string name = checkstringfield(L, 1, "name"); std::string name = checkstringfield(L, 1, "name");
loc.setPlayer(name); loc.setPlayer(name);
@ -431,22 +440,9 @@ int ModApiInventory::l_get_inventory(lua_State *L)
InvRef::create(L, loc); InvRef::create(L, loc);
else else
lua_pushnil(L); lua_pushnil(L);
return 1; return 1;
// END NO_MAP_LOCK_REQUIRED;
} }
else {
if(type == "node"){
lua_getfield(L, 1, "pos");
v3s16 pos = check_v3s16(L, -1);
loc.setNodeMeta(pos);
}
if(getServer(L)->getInventory(loc) != NULL)
InvRef::create(L, loc);
else
lua_pushnil(L);
return 1;
}
} }
// create_detached_inventory_raw(name) // create_detached_inventory_raw(name)