diff options
author | kwolekr <kwolekr@minetest.net> | 2013-04-21 12:55:46 -0400 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2013-09-26 04:39:10 +0200 |
commit | fb6a789991ba633a330bacaf0e915019a01b602f (patch) | |
tree | 2b47516b395a1fbfa8f4bbe3dc847741695718b2 /src/script | |
parent | 9e6bdc377fcbc8e4c795bd76d582197e8afb3530 (diff) | |
download | minetest-fb6a789991ba633a330bacaf0e915019a01b602f.tar.gz minetest-fb6a789991ba633a330bacaf0e915019a01b602f.tar.bz2 minetest-fb6a789991ba633a330bacaf0e915019a01b602f.zip |
Re-fix hud_change stat argument retrieval
Conflicts:
src/script/lua_api/l_object.cpp
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 6a800f15d..c324ced1a 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -877,16 +877,18 @@ int ObjectRef::l_hud_change(lua_State *L) if (player == NULL) return 0; - u32 id = -1; - if (!lua_isnil(L, 2)) - id = lua_tonumber(L, 2); - - HudElementStat stat = (HudElementStat)getenumfield(L, 3, "stat", - es_HudElementStat, HUD_STAT_NUMBER); - + u32 id = !lua_isnil(L, 2) ? lua_tonumber(L, 2) : -1; if (id >= player->hud.size()) return 0; + HudElementStat stat = HUD_STAT_NUMBER; + if (!lua_isnil(L, 3)) { + int statint; + std::string statstr = lua_tostring(L, 3); + stat = string_to_enum(es_HudElementStat, statint, statstr) ? + (HudElementStat)statint : HUD_STAT_NUMBER; + } + void *value = NULL; HudElement *e = player->hud[id]; if (!e) |