forked from github/server
neue lua-exporte:
- region.plane_id (readonly) - unit.region (read/write)
This commit is contained in:
parent
8d04c6a448
commit
763261092d
2 changed files with 26 additions and 5 deletions
|
@ -3,10 +3,11 @@
|
|||
#include "list.h"
|
||||
|
||||
// kernel includes
|
||||
#include <region.h>
|
||||
#include <unit.h>
|
||||
#include <building.h>
|
||||
#include <ship.h>
|
||||
#include <kernel/plane.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/ship.h>
|
||||
|
||||
// lua includes
|
||||
#include <lua.hpp>
|
||||
|
@ -61,6 +62,13 @@ region_getinfo(const region& r) {
|
|||
return r.display;
|
||||
}
|
||||
|
||||
static int
|
||||
region_plane(const region& r)
|
||||
{
|
||||
if (r.planep==NULL) return 0;
|
||||
return r.planep->id;
|
||||
}
|
||||
|
||||
void
|
||||
bind_region(lua_State * L)
|
||||
{
|
||||
|
@ -75,6 +83,7 @@ bind_region(lua_State * L)
|
|||
.def_readonly("x", ®ion::x)
|
||||
.def_readonly("y", ®ion::y)
|
||||
.def_readwrite("age", ®ion::age)
|
||||
.property("plane_id", ®ion_plane)
|
||||
.property("units", ®ion_units, return_stl_iterator)
|
||||
.property("buildings", ®ion_buildings, return_stl_iterator)
|
||||
.property("ships", ®ion_ships, return_stl_iterator)
|
||||
|
|
|
@ -191,6 +191,18 @@ unit_hpmax(const unit& u)
|
|||
return unit_max_hp(&u);
|
||||
}
|
||||
|
||||
static void
|
||||
unit_setregion(unit& u, region& r)
|
||||
{
|
||||
move_unit(&u, &r, NULL);
|
||||
}
|
||||
|
||||
static region *
|
||||
unit_getregion(const unit& u)
|
||||
{
|
||||
return u.region;
|
||||
}
|
||||
|
||||
void
|
||||
bind_unit(lua_State * L)
|
||||
{
|
||||
|
@ -201,7 +213,6 @@ bind_unit(lua_State * L)
|
|||
class_<struct unit>("unit")
|
||||
.def_readonly("name", &unit::name)
|
||||
.def_readonly("size", &unit::number)
|
||||
.def_readonly("region", &unit::region)
|
||||
.def_readonly("faction", &unit::faction)
|
||||
.def_readonly("id", &unit::no)
|
||||
.def_readwrite("hp", &unit::hp)
|
||||
|
@ -213,6 +224,7 @@ bind_unit(lua_State * L)
|
|||
.def("set_racename", &unit_setracename)
|
||||
.def("add_spell", &unit_addspell)
|
||||
.def("remove_spell", &unit_removespell)
|
||||
.property("region", &unit_getregion, &unit_setregion)
|
||||
.property("is_familiar", &unit_isfamiliar)
|
||||
.property("spells", &unit_spells, return_stl_iterator)
|
||||
.property("familiarspells", &unit_familiarspells, return_stl_iterator)
|
||||
|
|
Loading…
Reference in a new issue