diff --git a/src/eressea/lua/building.cpp b/src/eressea/lua/building.cpp index 2206d4521..aad03b575 100644 --- a/src/eressea/lua/building.cpp +++ b/src/eressea/lua/building.cpp @@ -96,7 +96,7 @@ building_setregion(building& b, region& r) } static std::ostream& -operator<<(std::ostream& stream, building& b) +operator<<(std::ostream& stream, const building& b) { stream << b.name; stream << " (" << itoa36(b.no) << ")"; @@ -132,6 +132,10 @@ building_units(const building& b) { return eressea::list(u); } +const char * +building_gettype(const building& b) { + return b.type->_name; +} void bind_building(lua_State * L) @@ -148,6 +152,7 @@ bind_building(lua_State * L) .property("info", &building_getinfo, &building_setinfo) .property("units", &building_units, return_stl_iterator) .property("region", &building_getregion, &building_setregion) + .def("type", &building_gettype) .def_readonly("id", &building::no) .def_readwrite("size", &building::size) .def("add_action", &building_addaction) diff --git a/src/eressea/lua/faction.cpp b/src/eressea/lua/faction.cpp index cd64bb797..85d65107f 100644 --- a/src/eressea/lua/faction.cpp +++ b/src/eressea/lua/faction.cpp @@ -74,7 +74,7 @@ faction_locale(const faction& f) } static std::ostream& -operator<<(std::ostream& stream, faction& f) +operator<<(std::ostream& stream, const faction& f) { stream << factionname(&f); return stream; diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp index 0f6c89051..529df8db6 100644 --- a/src/eressea/lua/region.cpp +++ b/src/eressea/lua/region.cpp @@ -80,7 +80,7 @@ region_addnotice(region& r, const char * str) } static std::ostream& -operator<<(std::ostream& stream, region& r) +operator<<(std::ostream& stream, const region& r) { stream << regionname(&r, NULL) << ", " << region_getterrain(r); return stream; diff --git a/src/eressea/lua/ship.cpp b/src/eressea/lua/ship.cpp index ad50052c0..e55b10af4 100644 --- a/src/eressea/lua/ship.cpp +++ b/src/eressea/lua/ship.cpp @@ -10,8 +10,27 @@ #include #include +#include + +#include using namespace luabind; +static std::ostream& +operator<<(std::ostream& stream, const ship& sh) +{ + stream << sh.name; + stream << " (" << itoa36(sh.no) << ")"; + stream << ", " << sh.type->name; + stream << " size " << sh.size; + return stream; +} + +static bool +operator==(const ship& a, const ship& sh) +{ + return a.no==sh.no; +} + void bind_ship(lua_State * L) { @@ -19,6 +38,8 @@ bind_ship(lua_State * L) def("get_ship", &findship), class_("ship") + .def(self == ship()) + .def(tostring(self)) .def_readonly("name", &ship::name) .def_readonly("region", &ship::region) .def_readonly("id", &ship::no) diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp index 1474ff384..9b5cb7ef3 100644 --- a/src/eressea/lua/unit.cpp +++ b/src/eressea/lua/unit.cpp @@ -325,7 +325,7 @@ set_flag(unit& u, const char * name, bool value) } static std::ostream& -operator<<(std::ostream& stream, unit& u) +operator<<(std::ostream& stream, const unit& u) { const char * rcname = get_racename(u.attribs); stream << u.name << " (" << itoa36(u.no) << "), " << u.number << " " << u.race->_name[0];