diff options
author | Blue <bluesansdouze@gmail.com> | 2009-05-02 01:32:38 +0200 |
---|---|---|
committer | Chuck Miller <shadowmil@gmail.com> | 2009-05-01 20:03:15 -0400 |
commit | 44c0334a9046db41db0b8dc281727218fe89c3f2 (patch) | |
tree | 3d831d714abf101b3c35af14844cec77bcb532fd /src/scripting/lua.cpp | |
parent | 7db58a9a70d8d2799525cf9eee94b826eaea198b (diff) | |
download | manaserv-44c0334a9046db41db0b8dc281727218fe89c3f2.tar.gz manaserv-44c0334a9046db41db0b8dc281727218fe89c3f2.tar.bz2 manaserv-44c0334a9046db41db0b8dc281727218fe89c3f2.tar.xz manaserv-44c0334a9046db41db0b8dc281727218fe89c3f2.zip |
tmwserv NPC String input
Adding support for npc string input.
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r-- | src/scripting/lua.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 68cdeca1..4cd2c52f 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -112,12 +112,10 @@ static int npc_choice(lua_State *s) /** * Callback for sending a NPC_INTEGER. - * tmw.npc_integer(npc, character, msg, min, max, defaut) + * tmw.npc_integer(npc, character, min, max, defaut) */ static int npc_ask_integer(lua_State *s) { - LOG_WARN("Appel de NPC Integer ! "); - NPC *p = getNPC(s, 1); Character *q = getCharacter(s, 2); if (!p || !q) @@ -138,7 +136,25 @@ static int npc_ask_integer(lua_State *s) msg.writeLong(default_num); gameHandler->sendTo(q, msg); - LOG_WARN("MSG SENT ! " << min << " ; " << max << " ; " << default_num << " ; "); + return 0; +} + +/** + * Callback for sending a NPC_STRING. + * tmw.npc_ask_string(npc, character) + */ +static int npc_ask_string(lua_State *s) +{ + NPC *p = getNPC(s, 1); + Character *q = getCharacter(s, 2); + if (!p || !q) + { + raiseScriptError(s, "npc_string called with incorrect parameters."); + return 0; + } + MessageOut msg(GPMSG_NPC_STRING); + msg.writeShort(p->getPublicID()); + gameHandler->sendTo(q, msg); return 0; } @@ -1212,6 +1228,7 @@ LuaScript::LuaScript(): { "item_drop", &item_drop }, { "npc_ask_integer", &npc_ask_integer }, { "npc_end", &npc_end }, + { "npc_ask_string", &npc_ask_string }, { NULL, NULL } }; luaL_register(mState, "tmw", callbacks); |