diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-01 21:54:04 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-02 22:57:47 +0100 |
commit | c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3 (patch) | |
tree | 8de105c5e154912acf354bbe1bbf8509ac44e25a /src/scripting/lua.cpp | |
parent | ba5b55f3eba0aa3898c5fe42de9838b22473c24a (diff) | |
download | manaserv-c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3.tar.gz manaserv-c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3.tar.bz2 manaserv-c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3.tar.xz manaserv-c0c208d4c29ff49f940e8a6c54adb26cc4e5eba3.zip |
Converted functions called by LuaScript to callbacks
This includes the quest reply, post reply, death notification and
remove notification.
Also, Script::Ref was changed from a typedef to a small class,
automating initialization and making the check for validness clearer.
Reviewed-by: Erik Schilling
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 7a94ce24..33bd9eb9 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -97,6 +97,34 @@ static int on_character_death_accept(lua_State *s) return 0; } +static int on_npc_quest_reply(lua_State *s) +{ + luaL_checktype(s, 1, LUA_TFUNCTION); + LuaScript::setQuestReplyCallback(getScript(s)); + return 0; +} + +static int on_npc_post_reply(lua_State *s) +{ + luaL_checktype(s, 1, LUA_TFUNCTION); + LuaScript::setPostReplyCallback(getScript(s)); + return 0; +} + +static int on_being_death(lua_State *s) +{ + luaL_checktype(s, 1, LUA_TFUNCTION); + LuaScript::setDeathNotificationCallback(getScript(s)); + return 0; +} + +static int on_being_remove(lua_State *s) +{ + luaL_checktype(s, 1, LUA_TFUNCTION); + LuaScript::setRemoveNotificationCallback(getScript(s)); + return 0; +} + /** * mana.npc_message(NPC*, Character*, string): void * Callback for sending a NPC_MESSAGE. @@ -2590,6 +2618,10 @@ LuaScript::LuaScript(): static luaL_Reg const callbacks[] = { { "on_character_death", &on_character_death }, { "on_character_death_accept", &on_character_death_accept }, + { "on_npc_quest_reply", &on_npc_quest_reply }, + { "on_npc_post_reply", &on_npc_post_reply }, + { "on_being_death", &on_being_death }, + { "on_being_remove", &on_being_remove }, { "npc_create", &npc_create }, { "npc_message", &npc_message }, { "npc_choice", &npc_choice }, |