summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2013-05-04 02:08:52 +0200
committerKahrl <kahrl@gmx.net>2013-05-26 00:23:33 +0200
commit96fe1de8322a57ad82fcab3540c1eb44f74b9989 (patch)
tree44bc5db4e9d002f2a1fb6506db72e390cabae249 /src/script
parent730d316efe18c57760cd5ec518a6191ac271ce61 (diff)
downloadminetest-96fe1de8322a57ad82fcab3540c1eb44f74b9989.tar.gz
minetest-96fe1de8322a57ad82fcab3540c1eb44f74b9989.tar.bz2
minetest-96fe1de8322a57ad82fcab3540c1eb44f74b9989.zip
Add ObjectRef.hud_set_hotbar_itemcount and add TOCLIENT_HUD_SET_PARAM
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_object.cpp18
-rw-r--r--src/script/lua_api/l_object.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 6dec3db85..1e45610a6 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -978,6 +978,23 @@ int ObjectRef::l_hud_set_flags(lua_State *L)
return 1;
}
+// hud_set_hotbar_itemcount(self, hotbar_itemcount)
+int ObjectRef::l_hud_set_hotbar_itemcount(lua_State *L)
+{
+ ObjectRef *ref = checkobject(L, 1);
+ Player *player = getplayer(ref);
+ if (player == NULL)
+ return 0;
+
+ s32 hotbar_itemcount = lua_tonumber(L, 2);
+
+ if (!STACK_TO_SERVER(L)->hudSetHotbarItemcount(player, hotbar_itemcount))
+ return 0;
+
+ lua_pushboolean(L, true);
+ return 1;
+}
+
ObjectRef::ObjectRef(ServerActiveObject *object):
m_object(object)
{
@@ -1089,6 +1106,7 @@ const luaL_reg ObjectRef::methods[] = {
luamethod(ObjectRef, hud_change),
luamethod(ObjectRef, hud_get),
luamethod(ObjectRef, hud_set_flags),
+ luamethod(ObjectRef, hud_set_hotbar_itemcount),
{0,0}
};
diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h
index 88f980a27..57dac0e64 100644
--- a/src/script/lua_api/l_object.h
+++ b/src/script/lua_api/l_object.h
@@ -209,6 +209,9 @@ private:
// hud_set_flags(self, flags)
static int l_hud_set_flags(lua_State *L);
+ // hud_set_hotbar_itemcount(self, hotbar_itemcount)
+ static int l_hud_set_hotbar_itemcount(lua_State *L);
+
public:
ObjectRef(ServerActiveObject *object);