aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorPierre-Yves Rollo <dev@pyrollo.com>2019-11-04 09:30:02 +0100
committerrubenwardy <rw@rubenwardy.com>2019-12-06 20:31:26 +0000
commitcf7fda00831372d981415f9a830513b2b28fdf25 (patch)
treead8d856fe0c85f3cb35e205a5df4b286e04bf9aa /src/script
parentf6de86ce4b9da21f16d3bcdbc0c55ce4cbe23067 (diff)
downloadminetest-cf7fda00831372d981415f9a830513b2b28fdf25.tar.gz
minetest-cf7fda00831372d981415f9a830513b2b28fdf25.tar.bz2
minetest-cf7fda00831372d981415f9a830513b2b28fdf25.zip
Add z-index management to HUD
Diffstat (limited to 'src/script')
-rw-r--r--src/script/common/c_content.cpp19
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;
}