diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2011-10-16 00:17:05 +0800 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2011-10-19 00:10:38 +0800 |
commit | e7ba7e0956c0d80573b9dabf144d050ad5ae4ef6 (patch) | |
tree | 27d6a22ac27687f4d4d05e0dd4407844d28e7eaf /src | |
parent | 1e6b7a30b7232dce7b8240441bed04912e06f666 (diff) | |
download | manaserv-e7ba7e0956c0d80573b9dabf144d050ad5ae4ef6.tar.gz manaserv-e7ba7e0956c0d80573b9dabf144d050ad5ae4ef6.tar.bz2 manaserv-e7ba7e0956c0d80573b9dabf144d050ad5ae4ef6.tar.xz manaserv-e7ba7e0956c0d80573b9dabf144d050ad5ae4ef6.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/scripting/lua.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
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); |