From d74fa36fb69737ac14af4e360a428da747c88e78 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Tue, 13 Mar 2012 19:15:00 +0100 Subject: Added being_get_mapid lua bind Another step for being able to make @commands scriptable Reviewed-by: bjorn. --- src/scripting/lua.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 0087672f..30b6ace8 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1160,7 +1160,7 @@ static int being_set_direction(lua_State *s) return 0; } -/* +/** * being_set_walkmask(Being*, string mask) * Sets the walkmask of a being */ @@ -1181,7 +1181,7 @@ static int being_set_walkmask(lua_State *s) /** * being_get_walkmask(Being*): string - * Returns the walkmask of a being + * Returns the walkmask of a being. */ static int being_get_walkmask(lua_State *s) { @@ -1199,6 +1199,21 @@ static int being_get_walkmask(lua_State *s) return 1; } +/** + * being_get_mapid(Being*): int + * Returns the id of the map where the being is located or nil if there is none. + */ +static int being_get_mapid(lua_State *s) +{ + Being *being = checkBeing(s, 1); + if (MapComposite *map = being->getMap()) + lua_pushinteger(s, map->getID()); + else + lua_pushnil(s); + + return 1; +} + /** * posX(Being*): int xcoord * Function for getting the x-coordinate of the position of a being. @@ -2271,6 +2286,7 @@ LuaScript::LuaScript(): { "being_get_base_attribute", &being_get_base_attribute }, { "being_set_walkmask", &being_set_walkmask }, { "being_get_walkmask", &being_get_walkmask }, + { "being_get_mapid", &being_get_mapid }, { "posX", &posX }, { "posY", &posY }, { "trigger_create", &trigger_create }, -- cgit v1.2.3-70-g09d2