mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-23 08:08:47 -05:00
Re-fix hud_change stat argument retrieval
Conflicts: src/script/lua_api/l_object.cpp
This commit is contained in:
parent
9e6bdc377f
commit
fb6a789991
@ -877,16 +877,18 @@ int ObjectRef::l_hud_change(lua_State *L)
|
|||||||
if (player == NULL)
|
if (player == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
u32 id = -1;
|
u32 id = !lua_isnil(L, 2) ? lua_tonumber(L, 2) : -1;
|
||||||
if (!lua_isnil(L, 2))
|
|
||||||
id = lua_tonumber(L, 2);
|
|
||||||
|
|
||||||
HudElementStat stat = (HudElementStat)getenumfield(L, 3, "stat",
|
|
||||||
es_HudElementStat, HUD_STAT_NUMBER);
|
|
||||||
|
|
||||||
if (id >= player->hud.size())
|
if (id >= player->hud.size())
|
||||||
return 0;
|
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;
|
void *value = NULL;
|
||||||
HudElement *e = player->hud[id];
|
HudElement *e = player->hud[id];
|
||||||
if (!e)
|
if (!e)
|
||||||
|
Loading…
Reference in New Issue
Block a user