aboutsummaryrefslogtreecommitdiff
path: root/src/scriptapi_object.cpp
diff options
context:
space:
mode:
authorDiego Martínez <kaeza@users.sf.net>2013-04-22 06:53:55 -0300
committerPerttu Ahola <celeron55@gmail.com>2013-04-23 09:34:10 +0300
commit7c37b1891adcddc0e7d11e5faafddaa554443318 (patch)
tree4abc3352ba67a5e43a1aeaf29bff7e54ecac0906 /src/scriptapi_object.cpp
parent58ded5cd27dd6e5ba740b22d8a3b0917f3d98150 (diff)
downloadminetest-7c37b1891adcddc0e7d11e5faafddaa554443318.tar.xz
Added support for alignment in HUD items
Diffstat (limited to 'src/scriptapi_object.cpp')
-rw-r--r--src/scriptapi_object.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/scriptapi_object.cpp b/src/scriptapi_object.cpp
index 9152c9eb3..c07f6565d 100644
--- a/src/scriptapi_object.cpp
+++ b/src/scriptapi_object.cpp
@@ -47,6 +47,7 @@ struct EnumString es_HudElementStat[] =
{HUD_STAT_NUMBER, "number"},
{HUD_STAT_ITEM, "item"},
{HUD_STAT_DIR, "direction"},
+ {HUD_STAT_ALIGN, "alignment"},
{0, NULL},
};
@@ -751,6 +752,10 @@ int ObjectRef::l_hud_add(lua_State *L)
elem->item = getintfield_default(L, 2, "item", 0);
elem->dir = getintfield_default(L, 2, "direction", 0);
+ lua_getfield(L, 2, "alignment");
+ elem->align = lua_istable(L, -1) ? read_v2f(L, -1) : v2f();
+ lua_pop(L, 1);
+
u32 id = get_server(L)->hudAdd(player, elem);
if (id == (u32)-1) {
delete elem;
@@ -833,6 +838,9 @@ int ObjectRef::l_hud_change(lua_State *L)
case HUD_STAT_DIR:
e->dir = lua_tonumber(L, 4);
value = &e->dir;
+ case HUD_STAT_ALIGN:
+ e->align = read_v2f(L, 4);
+ value = &e->align;
}
get_server(L)->hudChange(player, id, stat, value);