From 8a43d694173fa0197597ed54c4df4d89c3002e4f Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Mon, 1 Aug 2011 13:38:54 +0200 Subject: Added is_walkable lua function. mana.is_walkable(x, y) can now be used to check wether the pixel on the current map is walkable or not. Reviewed-by: Bertram. --- src/scripting/lua.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index c3a38bf..9a67c7c 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1835,6 +1835,35 @@ static int get_map_property(lua_State *s) return 1; } +/** + * bool mana.is_walkable(int x, int y) + * Returns whether the pixel on the map is walkable. + */ +static int is_walkable(lua_State *s) +{ + const int x = luaL_checkint(s, 1); + const int y = luaL_checkint(s, 2); + + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + Script *t = static_cast