2003-11-10 00:36:11 +01:00
|
|
|
#include <config.h>
|
|
|
|
#include <eressea.h>
|
|
|
|
|
|
|
|
// kernel includes
|
|
|
|
#include <ship.h>
|
|
|
|
#include <region.h>
|
|
|
|
|
|
|
|
// lua includes
|
|
|
|
#include <lua.hpp>
|
|
|
|
#include <luabind/luabind.hpp>
|
|
|
|
#include <luabind/iterator_policy.hpp>
|
|
|
|
|
2004-09-26 20:00:49 +02:00
|
|
|
#include <util/base36.h>
|
|
|
|
|
|
|
|
#include <ostream>
|
2003-11-10 00:36:11 +01:00
|
|
|
using namespace luabind;
|
|
|
|
|
2004-09-26 20:00:49 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2003-11-10 00:36:11 +01:00
|
|
|
void
|
|
|
|
bind_ship(lua_State * L)
|
|
|
|
{
|
|
|
|
module(L)[
|
|
|
|
def("get_ship", &findship),
|
|
|
|
|
|
|
|
class_<struct ship>("ship")
|
2004-09-26 20:00:49 +02:00
|
|
|
.def(self == ship())
|
|
|
|
.def(tostring(self))
|
2003-11-10 00:36:11 +01:00
|
|
|
.def_readonly("name", &ship::name)
|
|
|
|
.def_readonly("region", &ship::region)
|
|
|
|
.def_readonly("id", &ship::no)
|
|
|
|
.def_readonly("info", &ship::display)
|
|
|
|
.def_readwrite("damage", &ship::damage)
|
|
|
|
.def_readwrite("size", &ship::size)
|
2004-06-16 01:29:27 +02:00
|
|
|
.def_readwrite("coast", &ship::coast)
|
2003-11-10 00:36:11 +01:00
|
|
|
];
|
|
|
|
}
|