From 707a9e5252237c011c821644b9483cefe64f719c Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Fri, 16 Aug 2013 22:06:47 +0200 Subject: Allow abilities name for use_ability() --- src/scripting/lua.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 759ae50b..c151b9fa 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -2308,6 +2308,7 @@ static int entity_take_ability(lua_State *s) /** LUA entity:use_ability (being) * entity:use_ability(int ability) + * entity:use_ability(string ability) ** * Valid only for character and monster entities. * @@ -2319,21 +2320,22 @@ static int entity_take_ability(lua_State *s) static int entity_use_ability(lua_State *s) { Entity *b = checkBeing(s, 1); - const int ability = luaL_checkint(s, 2); + auto abilityInfo = checkAbility(s, 2); + const int id = abilityInfo->id; bool targetIsBeing = lua_gettop(s) == 3; auto *abilityComponent = b->getComponent(); if (targetIsBeing) { Entity *target = checkBeing(s, 3); - lua_pushboolean(s, abilityComponent->useAbilityOnBeing(*b, ability, + lua_pushboolean(s, abilityComponent->useAbilityOnBeing(*b, id, target)); } else { const int x = luaL_checkint(s, 3); const int y = luaL_checkint(s, 4); - lua_pushboolean(s, abilityComponent->useAbilityOnPoint(*b, ability, + lua_pushboolean(s, abilityComponent->useAbilityOnPoint(*b, id, x, y)); } -- cgit v1.2.3-70-g09d2