diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 0521e66e4..88dae3080 100755 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -1330,3 +1330,10 @@ function test_bug_1795_demons() assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1)) assert_equal(peasants+growth, r:get_resource("peasant")) end + +function test_faction_flags() + f = faction.create("noreply@eressea.de", "human", "de") + assert_equal(0, f.flags) + f.flags = 42 + assert_equal(42, f.flags) +end diff --git a/src/bindings/bind_faction.c b/src/bindings/bind_faction.c index d5efd226c..775cb5ab8 100644 --- a/src/bindings/bind_faction.c +++ b/src/bindings/bind_faction.c @@ -160,6 +160,14 @@ static int tolua_faction_get_flags(lua_State * L) return 1; } +static int tolua_faction_set_flags(lua_State * L) +{ + faction *self = (faction *) tolua_tousertype(L, 1, 0); + int flags = (int)tolua_tonumber(L, 2, self->flags); + self->flags = flags; + return 1; +} + static int tolua_faction_get_options(lua_State * L) { faction *self = (faction *) tolua_tousertype(L, 1, 0); @@ -525,7 +533,7 @@ void tolua_faction_open(lua_State * L) tolua_faction_set_age); tolua_variable(L, TOLUA_CAST "options", tolua_faction_get_options, tolua_faction_set_options); - tolua_variable(L, TOLUA_CAST "flags", tolua_faction_get_flags, NULL); + tolua_variable(L, TOLUA_CAST "flags", tolua_faction_get_flags, tolua_faction_set_flags); tolua_variable(L, TOLUA_CAST "lastturn", tolua_faction_get_lastturn, tolua_faction_set_lastturn);