diff options
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index d5c12c76..230c8a3c 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -482,6 +482,42 @@ static int npc_trade(lua_State *s) } /** + * Applies a status effect with id to the being given for a amount of time + * tmw.being_apply_status(Being *being, int id, int time) + */ + +static int being_apply_status(lua_State *s) +{ + if (!lua_isuserdata(s, 1) || !lua_isnumber(s, 2) || !lua_isnumber(s, 3)) + { + raiseScriptError(s, "being_apply_status called with incorrect parameters."); + return 0; + } + Being *being = getBeing(s, 1); + int id = lua_tointeger(s, 2); + int time = lua_tointeger(s, 3); + being->applyStatusEffect(id, time); + return 1; +} + +/** + * Returns true if a being has a status effect + * tmw.being_has_status(Being *being, int id) + */ +static int being_has_status(lua_State *s) +{ + if (!lua_isuserdata(s, 1) || !lua_isnumber(s, 2)) + { + raiseScriptError(s, "being_has_status called with incorrect parameters."); + return 0; + } + Being *being = getBeing(s, 1); + lua_pushboolean(s, being->hasStatusEffect(lua_tointeger(s,2))); + return 1; +} + + +/** * Returns the Thing type of the given Being * tmw.being_type(Being *being) */ @@ -499,6 +535,7 @@ static int being_type(lua_State *s) return 1; } + /** * Function for making a being walk to a position * being_walk(Being *being, int x, int y, int speed) @@ -1245,6 +1282,8 @@ LuaScript::LuaScript(): { "chr_get_hair_color", &chr_get_hair_color }, { "exp_for_level", &exp_for_level }, { "monster_create", &monster_create }, + { "being_apply_status", &being_apply_status }, + { "being_has_status", &being_has_status }, { "being_type", &being_type }, { "being_walk", &being_walk }, { "being_say", &being_say }, |