From f81fae399d1c3a527744c20e4bc49fb487dbb0cf Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Sun, 5 May 2013 00:22:13 +0200 Subject: Added entity:destination() bind --- src/scripting/lua.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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(); + 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 }, -- cgit