diff options
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/common/c_content.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 72142798e..fc1d82bcc 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -1851,11 +1851,13 @@ void read_hud_element(lua_State *L, HudElement *elem) elem->size = lua_istable(L, -1) ? read_v2s32(L, -1) : v2s32(); lua_pop(L, 1); - elem->name = getstringfield_default(L, 2, "name", ""); - elem->text = getstringfield_default(L, 2, "text", ""); - elem->number = getintfield_default(L, 2, "number", 0); - elem->item = getintfield_default(L, 2, "item", 0); - elem->dir = getintfield_default(L, 2, "direction", 0); + elem->name = getstringfield_default(L, 2, "name", ""); + elem->text = getstringfield_default(L, 2, "text", ""); + elem->number = getintfield_default(L, 2, "number", 0); + elem->item = getintfield_default(L, 2, "item", 0); + elem->dir = getintfield_default(L, 2, "direction", 0); + elem->z_index = MYMAX(S16_MIN, MYMIN(S16_MAX, + getintfield_default(L, 2, "z_index", 0))); // Deprecated, only for compatibility's sake if (elem->dir == 0) @@ -1921,6 +1923,9 @@ void push_hud_element(lua_State *L, HudElement *elem) push_v3f(L, elem->world_pos); lua_setfield(L, -2, "world_pos"); + + lua_pushnumber(L, elem->z_index); + lua_setfield(L, -2, "z_index"); } HudElementStat read_hud_change(lua_State *L, HudElement *elem, void **value) @@ -1978,6 +1983,10 @@ HudElementStat read_hud_change(lua_State *L, HudElement *elem, void **value) elem->size = read_v2s32(L, 4); *value = &elem->size; break; + case HUD_STAT_Z_INDEX: + elem->z_index = MYMAX(S16_MIN, MYMIN(S16_MAX, luaL_checknumber(L, 4))); + *value = &elem->z_index; + break; } return stat; } |