From 49a9992896a8d8bdcc8e4916cd8eaf23bf115fd5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 16 Oct 2010 21:10:46 -0700 Subject: [PATCH] bindings for ship.coast --- src/bindings/bind_ship.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/bindings/bind_ship.c b/src/bindings/bind_ship.c index b5a0e90a3..2162b9933 100644 --- a/src/bindings/bind_ship.c +++ b/src/bindings/bind_ship.c @@ -144,6 +144,27 @@ static int tolua_ship_set_flags(lua_State* L) return 0; } +static int tolua_ship_set_coast(lua_State* L) +{ + ship* self = (ship*)tolua_tousertype(L, 1, 0); + if (lua_isnil(L, 2)) { + self->coast = NODIRECTION; + } else if (lua_isnumber(L, 2)) { + self->coast = (direction_t)tolua_tonumber(L, 2, 0); + } + return 0; +} + +static int tolua_ship_get_coast(lua_State* L) +{ + ship* self = (ship*)tolua_tousertype(L, 1, 0); + if (self->coast) { + tolua_pushnumber(L, self->coast); + return 1; + } + return 0; +} + void tolua_ship_open(lua_State* L) @@ -163,6 +184,7 @@ tolua_ship_open(lua_State* L) tolua_variable(L, TOLUA_CAST "units", tolua_ship_get_units, NULL); tolua_variable(L, TOLUA_CAST "flags", &tolua_ship_get_flags, tolua_ship_set_flags); tolua_variable(L, TOLUA_CAST "region", tolua_ship_get_region, tolua_ship_set_region); + tolua_variable(L, TOLUA_CAST "coast", tolua_ship_get_coast, tolua_ship_set_coast); #ifdef TODO .property("type", &ship_gettype) .property("weight", &ship_getweight)