diff --git a/src/eressea/lua/faction.cpp b/src/eressea/lua/faction.cpp index f505732b9..81521c929 100644 --- a/src/eressea/lua/faction.cpp +++ b/src/eressea/lua/faction.cpp @@ -9,11 +9,15 @@ # include #endif +// util includes +#include + // lua includes #include #include #include +#include using namespace luabind; static faction * @@ -65,6 +69,19 @@ faction_locale(const faction& f) return locale_name(f.locale); } +static std::ostream& +operator<<(std::ostream& stream, faction& f) +{ + stream << factionname(&f); + return stream; +} + +static bool +operator==(const faction& a, const faction&b) +{ + return a.no==b.no; +} + void bind_faction(lua_State * L) { @@ -74,6 +91,8 @@ bind_faction(lua_State * L) def("add_faction", &add_faction), class_("faction") + .def(tostring(self)) + .def(self == faction()) .def_readonly("name", &faction::name) .def_readonly("password", &faction::passw) .def_readonly("email", &faction::email) diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp index f43831472..12065ef4d 100644 --- a/src/eressea/lua/region.cpp +++ b/src/eressea/lua/region.cpp @@ -14,6 +14,7 @@ #include #include +#include using namespace luabind; static eressea::list @@ -75,6 +76,19 @@ region_addnotice(region& r, const char * str) addmessage(&r, NULL, str, MSG_MESSAGE, ML_IMPORTANT); } +static std::ostream& +operator<<(std::ostream& stream, region& r) +{ + stream << regionname(&r, NULL) << ", " << region_getterrain(r); + return stream; +} + +static bool +operator==(const region& a, const region&b) +{ + return a.x==b.x && a.y==b.y; +} + void bind_region(lua_State * L) { @@ -83,6 +97,8 @@ bind_region(lua_State * L) def("get_region", &findregion), class_("region") + .def(tostring(self)) + .def(self == region()) .property("name", ®ion_getname, ®ion_setname) .property("info", ®ion_getinfo, ®ion_setinfo) .property("terrain", ®ion_getterrain) diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp index 45bf3b58e..03e0ffd61 100644 --- a/src/eressea/lua/unit.cpp +++ b/src/eressea/lua/unit.cpp @@ -15,6 +15,7 @@ #include #include +// util includes #include // lua includes diff --git a/src/scripts/default.lua b/src/scripts/default.lua index 36dd731ba..ffec46b60 100644 --- a/src/scripts/default.lua +++ b/src/scripts/default.lua @@ -1,18 +1,14 @@ -function unitid(u) - return u.name .. " (" .. itoa36(u.id) .. ")" -end - function teleport_all(map, grave) print("- teleporting all quest members to the grave") local index for index in map do local r = map[index] - local u - for u in r.units do - u.region = grave - print (" .teleported " .. unitid(u)) - grave:add_notice("Ein Portal öffnet sich, und " .. u.name .. " erscheint in " .. grave.name) - end + local u + for u in r.units do + u.region = grave + print (" .teleported " .. u) + grave:add_notice("Ein Portal öffnet sich, und " .. u.name .. " erscheint in " .. grave.name) + end end end @@ -32,7 +28,7 @@ function wyrm() for u in grave.units do if u.faction.id~=atoi36("rr") then teleport_all(map, grave) - break + break end end @@ -65,13 +61,13 @@ function write_emails() local key for key in locales do local locale = locales[key] - files[locale] = io.open(basepath .. "/emails." .. locale, "w") + files[locale] = io.open(basepath .. "/emails." .. locale, "w") end local faction for faction in factions() do -- print(faction.id .. " - " .. faction.locale) - files[faction.locale]:write(faction.email .. "\n") + files[faction.locale]:write(faction.email .. "\n") end for key in files do @@ -110,7 +106,6 @@ function process(orders) print("could not write game") return -1 end - end