From 7aa11a8de627b14bc6c33557b4ca5a6167e19fb0 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 31 Dec 2008 14:32:39 +0000 Subject: Add a function to return the type of a given being --- src/scripting/lua.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 0387f3bb..e2be2d3f 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -547,6 +547,24 @@ static int LuaNpc_Trade(lua_State *s) return 0; } +/** + * Returns the Thing type of the given Being + * tmw.being_type(Being *being) + */ +static int LuaBeing_Type(lua_State *s) +{ + if (!lua_isuserdata(s, 1) ) + { + raiseScriptError(s, "being_type called with incorrect parameters."); + return 0; + } + + Being *being = getBeing(s, 1); + if (!being) return 0; + lua_pushinteger(s, being->getType()); + return 1; +} + /** * Function for making a being walk to a position * being_walk(Being *being, int x, int y, int speed) @@ -1158,6 +1176,7 @@ LuaScript::LuaScript(): { "chr_give_exp", &LuaChr_GiveExp }, { "exp_for_level", &LuaExpForLevel }, { "monster_create", &LuaMonster_Create }, + { "being_type", &LuaBeing_Type }, { "being_walk", &LuaBeing_Walk }, { "being_say", &LuaBeing_Say }, { "being_damage", &LuaBeing_Damage }, -- cgit v1.2.3-70-g09d2