From 20fe6419f8d9564e7ab098ead53c6ef5da1519fa Mon Sep 17 00:00:00 2001 From: David Athay Date: Fri, 24 Oct 2008 15:18:02 +0000 Subject: Added post callback for getting post. Added GM command for changing player attributes. Changed GM command to @ as '/' was already being used by client for local commands. --- src/scripting/lua.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index f5365623..7f421c67 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -42,6 +42,7 @@ extern "C" { #include "game-server/monster.hpp" #include "game-server/monstermanager.hpp" #include "game-server/npc.hpp" +#include "game-server/postman.hpp" #include "game-server/quest.hpp" #include "game-server/state.hpp" #include "game-server/trigger.hpp" @@ -80,6 +81,9 @@ class LuaScript: public Script static void getQuestCallback(Character *, std::string const &, std::string const &, void *); + static void getPostCallback(Character *, std::string const &, + std::string const &, void *); + void processDeathEvent(Being* thing); private: @@ -637,6 +641,23 @@ void LuaScript::getQuestCallback(Character *q, std::string const &name, s->execute(); } +/** + * Called when the server has recovered the post for a user + */ +void LuaScript::getPostCallback(Character *q, std::string const &sender, + std::string const &letter, void *data) +{ + // get the script + LuaScript *s = static_cast(data); + assert(s->nbArgs == -1); + lua_getglobal(s->mState, "post_reply"); + lua_pushlightuserdata(s->mState, q); + lua_pushstring(s->mState, sender.c_str()); + lua_pushstring(s->mState, letter.c_str()); + s->nbArgs = 3; + s->execute(); +} + /** * Callback for getting a quest variable. Starts a recovery and returns * immediatly, if the variable is not known yet. @@ -807,7 +828,7 @@ static int LuaGetBeingsInCircle(lua_State *s) /** * Gets the post for the character */ -static int LuaGetPost(lua_State *s) +static int LuaChr_GetPost(lua_State *s) { if (lua_isuserdata(s, 1)) { @@ -815,7 +836,11 @@ static int LuaGetPost(lua_State *s) if (c) { - accountHandler->getPost(c); + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + Script *t = static_cast