neue lua-exporte:

- region:tostring
- region:operator==
- faction:tostring
- faction:operator==
This commit is contained in:
Enno Rehling 2004-04-11 16:16:26 +00:00
parent 5d559840fa
commit 82119094a7
4 changed files with 45 additions and 14 deletions

View File

@ -9,11 +9,15 @@
# include <modules/alliance.h>
#endif
// util includes
#include <util/base36.h>
// lua includes
#include <lua.hpp>
#include <luabind/luabind.hpp>
#include <luabind/iterator_policy.hpp>
#include <ostream>
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_<struct faction>("faction")
.def(tostring(self))
.def(self == faction())
.def_readonly("name", &faction::name)
.def_readonly("password", &faction::passw)
.def_readonly("email", &faction::email)

View File

@ -14,6 +14,7 @@
#include <luabind/luabind.hpp>
#include <luabind/iterator_policy.hpp>
#include <ostream>
using namespace luabind;
static eressea::list<region>
@ -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_<struct region>("region")
.def(tostring(self))
.def(self == region())
.property("name", &region_getname, &region_setname)
.property("info", &region_getinfo, &region_setinfo)
.property("terrain", &region_getterrain)

View File

@ -15,6 +15,7 @@
#include <kernel/magic.h>
#include <kernel/spell.h>
// util includes
#include <util/base36.h>
// lua includes

View File

@ -1,7 +1,3 @@
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
@ -10,7 +6,7 @@ function teleport_all(map, grave)
local u
for u in r.units do
u.region = grave
print (" .teleported " .. unitid(u))
print (" .teleported " .. u)
grave:add_notice("Ein Portal öffnet sich, und " .. u.name .. " erscheint in " .. grave.name)
end
end
@ -110,7 +106,6 @@ function process(orders)
print("could not write game")
return -1
end
end