Skip to content

Commit 2504da2

Browse files
rubenwardysfan5
authored andcommittedJan 7, 2015
Fix direction property of HUD
1 parent ef140eb commit 2504da2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed
 

‎src/script/lua_api/l_object.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ int ObjectRef::l_set_eye_offset(lua_State *L)
442442
// Do it
443443
v3f offset_first = v3f(0, 0, 0);
444444
v3f offset_third = v3f(0, 0, 0);
445-
445+
446446
if(!lua_isnil(L, 2))
447447
offset_first = read_v3f(L, 2);
448448
if(!lua_isnil(L, 3))
@@ -914,7 +914,11 @@ int ObjectRef::l_hud_add(lua_State *L)
914914
elem->text = getstringfield_default(L, 2, "text", "");
915915
elem->number = getintfield_default(L, 2, "number", 0);
916916
elem->item = getintfield_default(L, 2, "item", 0);
917-
elem->dir = getintfield_default(L, 2, "dir", 0);
917+
elem->dir = getintfield_default(L, 2, "direction", 0);
918+
919+
// Deprecated, only for compatibility's sake
920+
if (elem->dir == 0)
921+
elem->dir = getintfield_default(L, 2, "dir", 0);
918922

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

1082+
lua_pushnumber(L, e->dir);
1083+
lua_setfield(L, -2, "direction");
1084+
1085+
// Deprecated, only for compatibility's sake
10781086
lua_pushnumber(L, e->dir);
10791087
lua_setfield(L, -2, "dir");
10801088

@@ -1095,7 +1103,7 @@ int ObjectRef::l_hud_set_flags(lua_State *L)
10951103
u32 flags = 0;
10961104
u32 mask = 0;
10971105
bool flag;
1098-
1106+
10991107
const EnumString *esp = es_HudBuiltinElement;
11001108
for (int i = 0; esp[i].str; i++) {
11011109
if (getboolfield(L, 2, esp[i].str, flag)) {

0 commit comments

Comments
 (0)