aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_object.cpp
diff options
context:
space:
mode:
authorPilzAdam <pilzadam@minetest.net>2013-09-03 19:51:40 +0200
committerPilzAdam <pilzadam@minetest.net>2013-09-05 00:21:16 +0200
commit7860097eda449f0bb99971a037967bd338441133 (patch)
treebcc66bcb45cb8753f2d82c22973c9fc867774cfa /src/script/lua_api/l_object.cpp
parent5b518ed2feff28c9bf21ad940c1b211b72d71bd1 (diff)
downloadminetest-7860097eda449f0bb99971a037967bd338441133.tar.gz
minetest-7860097eda449f0bb99971a037967bd338441133.tar.bz2
minetest-7860097eda449f0bb99971a037967bd338441133.zip
Use player:set_hotbar_image() instead of hardcoded hotbar.png
Diffstat (limited to 'src/script/lua_api/l_object.cpp')
-rw-r--r--src/script/lua_api/l_object.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index c0da79c29..6a800f15d 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -1022,6 +1022,34 @@ int ObjectRef::l_hud_set_hotbar_itemcount(lua_State *L)
return 1;
}
+// hud_set_hotbar_image(self, name)
+int ObjectRef::l_hud_set_hotbar_image(lua_State *L)
+{
+ ObjectRef *ref = checkobject(L, 1);
+ Player *player = getplayer(ref);
+ if (player == NULL)
+ return 0;
+
+ std::string name = lua_tostring(L, 2);
+
+ getServer(L)->hudSetHotbarImage(player, name);
+ return 1;
+}
+
+// hud_set_hotbar_selected_image(self, name)
+int ObjectRef::l_hud_set_hotbar_selected_image(lua_State *L)
+{
+ ObjectRef *ref = checkobject(L, 1);
+ Player *player = getplayer(ref);
+ if (player == NULL)
+ return 0;
+
+ std::string name = lua_tostring(L, 2);
+
+ getServer(L)->hudSetHotbarSelectedImage(player, name);
+ return 1;
+}
+
ObjectRef::ObjectRef(ServerActiveObject *object):
m_object(object)
{
@@ -1136,5 +1164,7 @@ const luaL_reg ObjectRef::methods[] = {
luamethod(ObjectRef, hud_get),
luamethod(ObjectRef, hud_set_flags),
luamethod(ObjectRef, hud_set_hotbar_itemcount),
+ luamethod(ObjectRef, hud_set_hotbar_image),
+ luamethod(ObjectRef, hud_set_hotbar_selected_image),
{0,0}
};