From e7ba7e0956c0d80573b9dabf144d050ad5ae4ef6 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Sun, 16 Oct 2011 00:17:05 +0800 Subject: Made get_beings_in_circle capable of taking a being as argument. Instead of giving the x, y coordinates of the circle you can give a being which is in the center of the circle. --- src/scripting/lua.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 16781937..a322a3f9 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1414,14 +1414,27 @@ static int chat_message(lua_State *s) /** * mana.get_beings_in_circle(int x, int y, int radius): table of Being* + * mana.get_beings_in_circle(handle centerBeing, int radius): table of Being* * Gets a LUA table with the Being* pointers of all beings * inside of a circular area of the current map. */ static int get_beings_in_circle(lua_State *s) { - const int x = luaL_checkint(s, 1); - const int y = luaL_checkint(s, 2); - const int r = luaL_checkint(s, 3); + int x, y, r; + if (lua_islightuserdata(s, 1)) + { + Being *b = getBeing(s, 1); + const Point &pos = b->getPosition(); + x = pos.x; + y = pos.y; + r = luaL_checkint(s, 2); + } + else + { + x = luaL_checkint(s, 1); + y = luaL_checkint(s, 2); + r = luaL_checkint(s, 3); + } lua_pushlightuserdata(s, (void *)®istryKey); lua_gettable(s, LUA_REGISTRYINDEX); -- cgit v1.2.3-70-g09d2