diff options
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
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) { @@ -1200,6 +1200,21 @@ static int being_get_walkmask(lua_State *s) } /** + * 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 }, |