summaryrefslogtreecommitdiff
path: root/src/scripting
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-08-26 22:56:46 +0200
commit6f3c3563d2ec35da22faebba3289af0ac8be4137 (patch)
treea1b500a578d6ea404c0e27298debb656c7a63169 /src/scripting
parent5612cc82a1287df05b3298437f64f6dcc378a0f4 (diff)
downloadmanaserv-6f3c3563d2ec35da22faebba3289af0ac8be4137.tar.gz
manaserv-6f3c3563d2ec35da22faebba3289af0ac8be4137.tar.bz2
manaserv-6f3c3563d2ec35da22faebba3289af0ac8be4137.tar.xz
manaserv-6f3c3563d2ec35da22faebba3289af0ac8be4137.zip
Added entity:destination() bind
Diffstat (limited to 'src/scripting')
-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 726c14e0..6185e840 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1380,6 +1380,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])
**
@@ -3371,6 +3388,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 },