summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-05-05 00:22:13 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-05-11 23:31:15 +0200
commitf81fae399d1c3a527744c20e4bc49fb487dbb0cf (patch)
treefb7b193f4bd717a4288bc84b037b91bf4b6e9185
parent01df6f017d798a1973ab5c20d3d895cb7f86dcb5 (diff)
downloadmanaserv-f81fae399d1c3a527744c20e4bc49fb487dbb0cf.tar.gz
manaserv-f81fae399d1c3a527744c20e4bc49fb487dbb0cf.tar.xz
manaserv-f81fae399d1c3a527744c20e4bc49fb487dbb0cf.zip
Added entity:destination() bind
-rw-r--r--src/scripting/lua.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 75cb749..447b2ca 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1381,6 +1381,23 @@ static int entity_walk(lua_State *s)
return 0;
}
+/** LUA entity:destination (being)
+ * local x, y = entity:destination()
+ **
+ * Valid only for being entities.
+ *
+ * **Return value:** The x and y coordinates of the destination.
+ */
+static int entity_destination(lua_State *s)
+{
+ Entity *being = checkBeing(s, 1);
+ auto *beingComponent = being->getComponent<BeingComponent>();
+ const Point &point = beingComponent->getDestination();
+ lua_pushinteger(s, point.x);
+ lua_pushinteger(s, point.y);
+ return 2;
+}
+
/** LUA entity:heal (being)
* entity:heal([int value])
**
@@ -3366,6 +3383,7 @@ LuaScript::LuaScript():
{ "ability_mana", entity_get_ability_mana },
{ "cooldown_ability", entity_cooldown_ability },
{ "walk", entity_walk },
+ { "destination", entity_destination },
{ "heal", entity_heal },
{ "name", entity_get_name },
{ "type", entity_get_type },