From 5996ff324d4123d1b1c6adb1c81eb16dd5e7b466 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Mon, 7 Jul 2008 19:56:02 +0000 Subject: Implemented death listener for scripting engine. --- src/scripting/lua.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index ae9ff1b2..5a9364db 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -79,6 +79,8 @@ class LuaScript: public Script static void getQuestCallback(Character *, std::string const &, std::string const &, void *); + void processDeathEvent(Being* thing); + private: lua_State *mState; @@ -721,6 +723,33 @@ static int LuaGetBeingsInCircle(lua_State *s) return 1; } +/** + * Makes the server call the lua function deathEvent + * with the being ID when the being dies. + * tmw.noteOnDeath (being) + */ +static int LuaNoteOnDeath(lua_State *s) +{ + if (!lua_islightuserdata(s, 1) || lua_gettop(s) != 1) + { + raiseScriptError(s, "lua_noteOnDeath called with incorrect parameters."); + return 0; + } + + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + Script *t = static_cast