Skip to content

Commit

Permalink
Fix direction property of HUD
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy authored and sfan5 committed Jan 7, 2015
1 parent ef140eb commit 2504da2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/script/lua_api/l_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ int ObjectRef::l_set_eye_offset(lua_State *L)
// Do it
v3f offset_first = v3f(0, 0, 0);
v3f offset_third = v3f(0, 0, 0);

if(!lua_isnil(L, 2))
offset_first = read_v3f(L, 2);
if(!lua_isnil(L, 3))
Expand Down Expand Up @@ -914,7 +914,11 @@ int ObjectRef::l_hud_add(lua_State *L)
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, "dir", 0);
elem->dir = getintfield_default(L, 2, "direction", 0);

// Deprecated, only for compatibility's sake
if (elem->dir == 0)
elem->dir = getintfield_default(L, 2, "dir", 0);

lua_getfield(L, 2, "alignment");
elem->align = lua_istable(L, -1) ? read_v2f(L, -1) : v2f();
Expand Down Expand Up @@ -1075,6 +1079,10 @@ int ObjectRef::l_hud_get(lua_State *L)
lua_pushnumber(L, e->item);
lua_setfield(L, -2, "item");

lua_pushnumber(L, e->dir);
lua_setfield(L, -2, "direction");

// Deprecated, only for compatibility's sake
lua_pushnumber(L, e->dir);
lua_setfield(L, -2, "dir");

Expand All @@ -1095,7 +1103,7 @@ int ObjectRef::l_hud_set_flags(lua_State *L)
u32 flags = 0;
u32 mask = 0;
bool flag;

const EnumString *esp = es_HudBuiltinElement;
for (int i = 0; esp[i].str; i++) {
if (getboolfield(L, 2, esp[i].str, flag)) {
Expand Down

0 comments on commit 2504da2

Please sign in to comment.