From d779224809cefad7a4df27873e92f5251fd132f7 Mon Sep 17 00:00:00 2001 From: Ablu Date: Sun, 26 Jun 2011 14:32:36 +0200 Subject: Added LUA function get_beings_in_rectangle. Reviewed-by: Bertram. Resolves: Mana-Mantis #369. --- src/scripting/lua.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index ab5d6566..d55fb132 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1301,6 +1301,44 @@ static int get_beings_in_circle(lua_State *s) return 1; } +/** + * Gets a LUA table with the being IDs of all beings + * inside of a recangular area of the current map. + * mana.get_beings_in_rectangle (x, y, width, height) + */ +static int get_beings_in_rectangle(lua_State *s) +{ + const int x = luaL_checkint(s, 1); + const int y = luaL_checkint(s, 2); + const int w = luaL_checkint(s, 3); + const int h = luaL_checkint(s, 4); + + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + Script *t = static_cast