forked from github/server
allow setting a faction's magic school from Lua
This commit is contained in:
parent
24cba1bea7
commit
d58e853074
|
@ -14,11 +14,12 @@ function test_roi()
|
|||
u.race = "elf"
|
||||
u:set_skill("magic", 10)
|
||||
u:add_item("money", 3010)
|
||||
f.magic = "tybied"
|
||||
u.magic = "tybied"
|
||||
u.aura = 200
|
||||
u.ship = s1
|
||||
local err = u:add_spell("create_roi")
|
||||
assert_equal(0, err)
|
||||
-- local err = u:add_spell("create_roi")
|
||||
-- assert_equal(0, err)
|
||||
u:clear_orders()
|
||||
u:add_order("ZAUBERE 'Erschaffe einen Ring der Unsichtbarkeit' ")
|
||||
process_orders()
|
||||
|
|
|
@ -117,6 +117,28 @@ static int tolua_faction_set_id(lua_State * L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_magic(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, magic_school[self->magiegebiet]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_magic(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
const char *type = tolua_tostring(L, 2, 0);
|
||||
magic_t mtype;
|
||||
|
||||
for (mtype = 0; mtype != MAXMAGIETYP; ++mtype) {
|
||||
if (strcmp(magic_school[mtype], type) == 0) {
|
||||
self->magiegebiet = mtype;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_age(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
|
@ -498,6 +520,8 @@ void tolua_faction_open(lua_State * L)
|
|||
tolua_variable(L, TOLUA_CAST "alliance", tolua_faction_get_alliance,
|
||||
tolua_faction_set_alliance);
|
||||
tolua_variable(L, TOLUA_CAST "score", tolua_faction_get_score, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "magic", &tolua_faction_get_magic,
|
||||
tolua_faction_set_magic);
|
||||
tolua_variable(L, TOLUA_CAST "age", tolua_faction_get_age,
|
||||
tolua_faction_set_age);
|
||||
tolua_variable(L, TOLUA_CAST "options", tolua_faction_get_options,
|
||||
|
|
|
@ -1745,6 +1745,7 @@ struct spellbook * unit_get_spellbook(struct unit * u)
|
|||
if (u->faction->spellbook) {
|
||||
return u->faction->spellbook;
|
||||
}
|
||||
return get_spellbook(magic_school[u->faction->magiegebiet]);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue