diff options
author | Philipp Sehmisch <mana@crushnet.org> | 2010-02-25 20:21:59 +0100 |
---|---|---|
committer | Philipp Sehmisch <mana@crushnet.org> | 2010-02-25 20:21:59 +0100 |
commit | c5252ab6c58a7680f5d8ab49fc7ecb17fa778c7c (patch) | |
tree | 36237d241f7ba778e480be9b704c580edafb616d /src/scripting | |
parent | e993ea11bfc211fa69a08838f0d9f1ca069e9e37 (diff) | |
download | manaserv-c5252ab6c58a7680f5d8ab49fc7ecb17fa778c7c.tar.gz manaserv-c5252ab6c58a7680f5d8ab49fc7ecb17fa778c7c.tar.bz2 manaserv-c5252ab6c58a7680f5d8ab49fc7ecb17fa778c7c.tar.xz manaserv-c5252ab6c58a7680f5d8ab49fc7ecb17fa778c7c.zip |
Added script bindings for healing characters and other beings.
Reviewed-by: Jared Adams <jaxad0127@gmail.com>
Diffstat (limited to 'src/scripting')
-rw-r--r-- | src/scripting/lua.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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 @@ -660,6 +660,39 @@ static int being_damage(lua_State *s) } /** + * 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 }, |