From c5252ab6c58a7680f5d8ab49fc7ecb17fa778c7c Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Thu, 25 Feb 2010 20:21:59 +0100 Subject: Added script bindings for healing characters and other beings. Reviewed-by: Jared Adams --- src/scripting/lua.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 034e9b41..c386c35d 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -659,6 +659,39 @@ static int being_damage(lua_State *s) return 0; } +/** + * Restores hit points of a being + * mana.being_heal(being[, value]) + * Without a value it heals fully. + */ +static int being_heal(lua_State *s) +{ + Being *being = getBeing(s, 1); + if (!being) + { + raiseScriptError(s, + "being_heal called for nonexistent being."); + return 0; + } + + if (lua_gettop(s) == 1) // when there is only one argument + { + being->heal(); + } + else if (lua_isnumber(s, 2)) + { + being->heal(lua_tointeger(s, 2)); + } + else + { + raiseScriptError(s, + "being_heal called with illegal healing value."); + } + + return 0; +} + + /** * Gets the attribute for a being * mana.being_get_attribute(being, attribute) @@ -1511,6 +1544,7 @@ LuaScript::LuaScript(): { "being_walk", &being_walk }, { "being_say", &being_say }, { "being_damage", &being_damage }, + { "being_heal", &being_heal }, { "being_get_attribute", &being_get_attribute }, { "being_get_name", &being_get_name }, { "being_get_action", &being_get_action }, -- cgit v1.2.3-70-g09d2