File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -877,16 +877,18 @@ int ObjectRef::l_hud_change(lua_State *L)
877
877
if (player == NULL )
878
878
return 0 ;
879
879
880
- u32 id = -1 ;
881
- if (!lua_isnil (L, 2 ))
882
- id = lua_tonumber (L, 2 );
883
-
884
- HudElementStat stat = (HudElementStat)getenumfield (L, 3 , " stat" ,
885
- es_HudElementStat, HUD_STAT_NUMBER);
886
-
880
+ u32 id = !lua_isnil (L, 2 ) ? lua_tonumber (L, 2 ) : -1 ;
887
881
if (id >= player->hud .size ())
888
882
return 0 ;
889
883
884
+ HudElementStat stat = HUD_STAT_NUMBER;
885
+ if (!lua_isnil (L, 3 )) {
886
+ int statint;
887
+ std::string statstr = lua_tostring (L, 3 );
888
+ stat = string_to_enum (es_HudElementStat, statint, statstr) ?
889
+ (HudElementStat)statint : HUD_STAT_NUMBER;
890
+ }
891
+
890
892
void *value = NULL ;
891
893
HudElement *e = player->hud [id];
892
894
if (!e)
You can’t perform that action at this time.
0 commit comments