summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_inventory.cpp
diff options
context:
space:
mode:
authorMetaDucky <metaducky AT gmail DOT com>2013-05-26 11:27:06 +0200
committerKahrl <kahrl@gmx.net>2013-06-01 12:15:11 +0200
commit64627817fcca52f20948c24b60ce192b218f6ce2 (patch)
treeb5461d505390f4f1987fcbf5a9e1dae3e0cbbbb7 /src/script/lua_api/l_inventory.cpp
parenta61aa6690b5a5bf804c6de22eed95a68ba480e7d (diff)
downloadminetest-64627817fcca52f20948c24b60ce192b218f6ce2.tar.gz
minetest-64627817fcca52f20948c24b60ce192b218f6ce2.tar.bz2
minetest-64627817fcca52f20948c24b60ce192b218f6ce2.zip
Fix minetest.get_inventory(loc) always returning nil for "node" type loc
Diffstat (limited to 'src/script/lua_api/l_inventory.cpp')
-rw-r--r--src/script/lua_api/l_inventory.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/script/lua_api/l_inventory.cpp b/src/script/lua_api/l_inventory.cpp
index 6dfb7a28c..1404c3c8a 100644
--- a/src/script/lua_api/l_inventory.cpp
+++ b/src/script/lua_api/l_inventory.cpp
@@ -416,9 +416,18 @@ int ModApiInventory::l_get_inventory(lua_State *L)
std::string type = checkstringfield(L, 1, "type");
- if(type != "pos"){
- NO_MAP_LOCK_REQUIRED;
+ 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;
+ } else {
+ NO_MAP_LOCK_REQUIRED;
if(type == "player"){
std::string name = checkstringfield(L, 1, "name");
loc.setPlayer(name);
@@ -431,22 +440,9 @@ int ModApiInventory::l_get_inventory(lua_State *L)
InvRef::create(L, loc);
else
lua_pushnil(L);
-
- return 1;
- }
- 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;
+ return 1;
+ // END NO_MAP_LOCK_REQUIRED;
}
-
}
// create_detached_inventory_raw(name)