#include #include #include "list.h" // kernel includes #include #include #include #include #include // lua includes #include #include #include using namespace luabind; static eressea::list get_regions(void) { return eressea::list(regions); } static eressea::list region_units(const region& r) { return eressea::list(r.units); } static eressea::list region_buildings(const region& r) { return eressea::list(r.buildings); } static eressea::list region_ships(const region& r) { return eressea::list(r.ships); } static void region_setname(region& r, const char * name) { if (r.land) rsetname((&r), name); } static const char * region_getterrain(const region& r) { return terrain[r.terrain].name; } static const char * region_getname(const region& r) { if (r.land) return r.land->name; return terrain[r.terrain].name; } static void region_setinfo(region& r, const char * info) { set_string(&r.display, info); } static const char * 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; } static void region_addnotice(region& r, const char * str) { addmessage(&r, NULL, str, MSG_MESSAGE, ML_IMPORTANT); } void bind_region(lua_State * L) { module(L)[ def("regions", &get_regions, return_stl_iterator), def("get_region", &findregion), class_("region") .property("name", ®ion_getname, ®ion_setname) .property("info", ®ion_getinfo, ®ion_setinfo) .property("terrain", ®ion_getterrain) .def("add_notice", ®ion_addnotice) .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) ]; }