diff --git a/src/eressea/lua/eressea.cpp b/src/eressea/lua/eressea.cpp index befeddda5..7f3c67865 100644 --- a/src/eressea/lua/eressea.cpp +++ b/src/eressea/lua/eressea.cpp @@ -70,7 +70,7 @@ find_plane_id(const char * name) } static bool -get_flag(const char * name) +get_key(const char * name) { int flag = atoi36(name); attrib * a = find_key(global.attribs, flag); @@ -78,7 +78,7 @@ get_flag(const char * name) } static void -set_flag(const char * name, bool value) +set_key(const char * name, bool value) { int flag = atoi36(name); attrib * a = find_key(global.attribs, flag); @@ -252,8 +252,8 @@ bind_eressea(lua_State * L) def("set_string", &lua_setstring), def("get_string", &lua_getstring), - def("set_flag", &set_flag), - def("get_flag", &get_flag), + def("set_key", &set_key), + def("get_key", &get_key), def("get_gamename", &get_gamename), /* planes not really implemented */ diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp index 878421244..06028bef5 100644 --- a/src/eressea/lua/region.cpp +++ b/src/eressea/lua/region.cpp @@ -13,6 +13,8 @@ #include #include +#include + // lua includes #include #include @@ -306,6 +308,27 @@ region_additem(region& r, const char * iname, int number) return -1; } +static bool +region_getkey(region& r, const char * name) +{ + int flag = atoi36(name); + attrib * a = find_key(r.attribs, flag); + return (a!=NULL); +} + +static void +region_setkey(region& r, const char * name, bool value) +{ + int flag = atoi36(name); + attrib * a = find_key(r.attribs, flag); + if (a==NULL && value) { + add_key(&r.attribs, flag); + } else if (a!=NULL && !value) { + a_remove(&r.attribs, a); + } +} + + void bind_region(lua_State * L) { @@ -326,6 +349,9 @@ bind_region(lua_State * L) .def("add_notice", ®ion_addnotice) .def("add_direction", ®ion_adddirection) + .def("get_key", ®ion_getkey) + .def("set_key", ®ion_setkey) + .def("get_flag", ®ion_getflag) .def("set_flag", ®ion_setflag)