From 90f24a0ae4ab244b6e6167db2421c145fa8bebe1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 28 Jul 2005 12:42:46 +0000 Subject: [PATCH] neat trick to extract the origin from a faction in LUA --- src/eressea/lua/faction.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/eressea/lua/faction.cpp b/src/eressea/lua/faction.cpp index 3da97b23a..5a7745168 100644 --- a/src/eressea/lua/faction.cpp +++ b/src/eressea/lua/faction.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #ifdef HAVE_LUABIND_B7 # include #endif @@ -217,6 +219,29 @@ faction_get_email(const faction& f) return f.email; } +void +faction_getorigin(const faction& f, int &x, int &y) +{ + ursprung * origin = f.ursprung; + while (origin!=NULL && origin->id!=0) { + origin = origin->next; + } + if (origin) { + x = origin->x; + y = origin->y; + } else { + x = 0; + y = 0; + } +} + +void +faction_setorigin(faction& f, int x, int y) +{ + x = 0; + y = 0; +} + void bind_faction(lua_State * L) { @@ -224,6 +249,7 @@ bind_faction(lua_State * L) def("factions", &get_factions, return_stl_iterator), def("get_faction", &findfaction), def("add_faction", &add_faction), + def("faction_origin", &faction_getorigin, pure_out_value(_2) + pure_out_value(_3)), class_("faction") .def(tostring(self)) @@ -242,6 +268,7 @@ bind_faction(lua_State * L) .def("add_item", &faction_additem) .property("items", &faction_items, return_stl_iterator) + //.property("origin", &faction_getorigin, &faction_setorigin, pure_out_value(_2) + pure_out_value(_3), copy) .def("add_notice", &faction_addnotice) .property("password", &faction_get_passw, &faction_set_passw)