diff options
author | sapier <Sapier at GMX dot net> | 2014-05-25 14:34:32 +0200 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-05-31 22:32:44 +0200 |
commit | d76b8c6e7ca96b33b706ef42a8e301531c592fea (patch) | |
tree | a59d14f8f3010363faf596cb0acdfddd5d105ac0 /src/script/lua_api/l_object.cpp | |
parent | 5bd2aea663945d467744749579a1812f2e47bde7 (diff) | |
download | minetest-d76b8c6e7ca96b33b706ef42a8e301531c592fea.tar.gz minetest-d76b8c6e7ca96b33b706ef42a8e301531c592fea.tar.bz2 minetest-d76b8c6e7ca96b33b706ef42a8e301531c592fea.zip |
Small cleanup of hud add/remove code
Diffstat (limited to 'src/script/lua_api/l_object.cpp')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 704037437..a556439dc 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -971,7 +971,9 @@ int ObjectRef::l_hud_change(lua_State *L) return 0; u32 id = !lua_isnil(L, 2) ? lua_tonumber(L, 2) : -1; - if (id >= player->hud.size()) + + HudElement *e = player->getHud(id); + if (!e) return 0; HudElementStat stat = HUD_STAT_NUMBER; @@ -983,10 +985,6 @@ int ObjectRef::l_hud_change(lua_State *L) } void *value = NULL; - HudElement *e = player->hud[id]; - if (!e) - return 0; - switch (stat) { case HUD_STAT_POS: e->pos = read_v2f(L, 4); @@ -1049,10 +1047,8 @@ int ObjectRef::l_hud_get(lua_State *L) return 0; u32 id = lua_tonumber(L, -1); - if (id >= player->hud.size()) - return 0; - HudElement *e = player->hud[id]; + HudElement *e = player->getHud(id); if (!e) return 0; |