From 37a627f2e9d0de8d198f23cb363aacb1acf1f281 Mon Sep 17 00:00:00 2001 From: David Athay Date: Thu, 6 Nov 2008 16:10:05 +0000 Subject: Added sending post via NPC. --- src/scripting/lua.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 38b044d..c86d577 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -313,6 +313,28 @@ static int LuaNpc_Create(lua_State *s) return 1; } +/** + * Callback for sending a NPC_POST. + * tmw.npc_post(npc, character) + */ +static int LuaNPC_Post(lua_State *s) +{ + NPC *p = getNPC(s, 1); + Character *q = getCharacter(s, 2); + + if (!p || !q) + { + raiseScriptError(s, "npc_Choice called with incorrect parameters."); + return 0; + } + + MessageOut msg(GPMSG_NPC_POST); + msg.writeShort(p->getPublicID()); + gameHandler->sendTo(q, msg); + + return 0; +} + /** * Enable a NPC if it has previously disabled * tmw.npc_enable(npc) @@ -1126,6 +1148,7 @@ LuaScript::LuaScript(): { "npc_message", &LuaNpc_Message }, { "npc_choice", &LuaNpc_Choice }, { "npc_trade", &LuaNpc_Trade }, + { "npc_post", &LuaNPC_Post }, { "npc_enable", &LuaNPC_Enable }, { "npc_disable", &LuaNPC_Disable }, { "chr_warp", &LuaChr_Warp }, -- cgit