summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_object.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-08-07 19:16:31 +0200
committerGitHub <noreply@github.com>2019-08-07 19:16:31 +0200
commite462a9a5ef46776d974203bb44e0b89e8c980b29 (patch)
tree4562ef5587bd896890d843877031d5818de19bbc /src/script/lua_api/l_object.cpp
parent003af7421352ec1b8ba0d230b807862e1e4cc7e9 (diff)
downloadminetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.tar.gz
minetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.tar.bz2
minetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.zip
Unify wield item handling (#8677)
This moves the wield item functions to Player and the tool utils for range calculation Also 'local_inventory' was removed due to redundancy in Client
Diffstat (limited to 'src/script/lua_api/l_object.cpp')
-rw-r--r--src/script/lua_api/l_object.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index ad8554834..5dba63159 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -308,8 +308,9 @@ int ObjectRef::l_get_wield_list(lua_State *L)
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
- if (co == NULL) return 0;
- // Do it
+ if (!co)
+ return 0;
+
lua_pushstring(L, co->getWieldList().c_str());
return 1;
}
@@ -320,8 +321,9 @@ int ObjectRef::l_get_wield_index(lua_State *L)
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
- if (co == NULL) return 0;
- // Do it
+ if (!co)
+ return 0;
+
lua_pushinteger(L, co->getWieldIndex() + 1);
return 1;
}
@@ -332,12 +334,12 @@ int ObjectRef::l_get_wielded_item(lua_State *L)
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
- if (co == NULL) {
+ if (!co) {
// Empty ItemStack
LuaItemStack::create(L, ItemStack());
return 1;
}
- // Do it
+
LuaItemStack::create(L, co->getWieldedItem());
return 1;
}