bind faction.flags to Lua

This commit is contained in:
Enno Rehling 2013-02-23 17:23:47 -08:00
parent 79feb5723c
commit 841876e335
2 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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);