diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-07-18 21:08:18 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-07-18 21:08:18 -0600 |
commit | 5c3f23831986dda46d1c41b8316dd901f1bf3164 (patch) | |
tree | 4949ea4b2ce9564636da33b11351f94ec04cfbf3 /src/scripting/lua.cpp | |
parent | 1923fcab4fc9aefd3eaa97fd9ca9b1c507bb4bcb (diff) | |
download | manaserv-5c3f23831986dda46d1c41b8316dd901f1bf3164.tar.gz manaserv-5c3f23831986dda46d1c41b8316dd901f1bf3164.tar.bz2 manaserv-5c3f23831986dda46d1c41b8316dd901f1bf3164.tar.xz manaserv-5c3f23831986dda46d1c41b8316dd901f1bf3164.zip |
Change status effects to prevent duplication
Also add some functions for manipulating status effects:
* removeStatusEffect
* getStatusEffectTime
* setStatusEffectTime
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 230c8a3c..7361cea0 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -501,7 +501,23 @@ static int being_apply_status(lua_State *s) } /** - * Returns true if a being has a status effect + * Removes the given status effect + * tmw.being_remove_status(Being *being, int id) + */ +static int being_remove_status(lua_State *s) +{ + if (!lua_isuserdata(s, 1) || !lua_isnumber(s, 2)) + { + raiseScriptError(s, "being_remove_status called with incorrect parameters."); + return 0; + } + Being *being = getBeing(s, 1); + being->removeStatusEffect(lua_tointeger(s,2)); + return 1; +} + +/** + * Returns true if a being has the given status effect * tmw.being_has_status(Being *being, int id) */ static int being_has_status(lua_State *s) @@ -516,6 +532,38 @@ static int being_has_status(lua_State *s) return 1; } +/** + * Returns the time left on the given status effect + * tmw.being_get_status_time(Being *being, int id) + */ +static int being_get_status_time(lua_State *s) +{ + if (!lua_isuserdata(s, 1) || !lua_isnumber(s, 2)) + { + raiseScriptError(s, "being_time_status called with incorrect parameters."); + return 0; + } + Being *being = getBeing(s, 1); + lua_pushinteger(s, being->getStatusEffectTime(lua_tointeger(s,2))); + return 1; +} + +/** + * Sets the time left on the given status effect + * tmw.being_set_status_time(Being *being, int id) + */ +static int being_set_status_time(lua_State *s) +{ + if (!lua_isuserdata(s, 1) || !lua_isnumber(s, 2) || !lua_isnumber(s, 3)) + { + raiseScriptError(s, "being_time_status called with incorrect parameters."); + return 0; + } + Being *being = getBeing(s, 1); + being->setStatusEffectTime(lua_tointeger(s,2), lua_tointeger(s,3)); + return 1; +} + /** * Returns the Thing type of the given Being @@ -1283,7 +1331,10 @@ LuaScript::LuaScript(): { "exp_for_level", &exp_for_level }, { "monster_create", &monster_create }, { "being_apply_status", &being_apply_status }, + { "being_remove_status", &being_remove_status }, { "being_has_status", &being_has_status }, + { "being_set_status_time", &being_set_status_time}, + { "being_get_status_time", &being_get_status_time}, { "being_type", &being_type }, { "being_walk", &being_walk }, { "being_say", &being_say }, |