summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2008-12-31 14:32:39 +0000
committerJared Adams <jaxad0127@gmail.com>2009-01-06 08:12:07 +0000
commit7aa11a8de627b14bc6c33557b4ca5a6167e19fb0 (patch)
tree3a5be974a41a350be3606b3f03d1a32fbf5741d9
parentec04039c308f07e88777d465142656f1fd2326f4 (diff)
downloadmanaserv-7aa11a8de627b14bc6c33557b4ca5a6167e19fb0.tar.gz
manaserv-7aa11a8de627b14bc6c33557b4ca5a6167e19fb0.tar.bz2
manaserv-7aa11a8de627b14bc6c33557b4ca5a6167e19fb0.tar.xz
manaserv-7aa11a8de627b14bc6c33557b4ca5a6167e19fb0.zip
Add a function to return the type of a given being
-rw-r--r--src/scripting/lua.cpp19
1 files changed, 19 insertions, 0 deletions
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
@@ -548,6 +548,24 @@ static int LuaNpc_Trade(lua_State *s)
}
/**
+ * 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 },