summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-10 17:42:13 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-10 17:42:13 +0000
commitde75c0a271c06e5569ec280ea04daadb9d4fea0c (patch)
tree148453282ec5d4196757af0725ea4f7463bab97d
parentf562abbf2980c66e5c16f30ea667b758e796ae4e (diff)
downloadmanaserv-de75c0a271c06e5569ec280ea04daadb9d4fea0c.tar.gz
manaserv-de75c0a271c06e5569ec280ea04daadb9d4fea0c.tar.xz
manaserv-de75c0a271c06e5569ec280ea04daadb9d4fea0c.zip
Removed colon in NPC choice messages.
-rw-r--r--ChangeLog2
-rw-r--r--data/test.lua10
-rw-r--r--src/scripting/lua.cpp15
3 files changed, 17 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 72ce917..215618b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,7 @@
src/game-server/mapcomposite.cpp, src/game-server/mapcomposite.hpp:
Associated scripts to maps.
* src/scripting/lua.cpp, data/test.lua: Added Lua function for warping
- people around.
+ people around. Removed colon in NPC choice messages.
2007-08-09 Guillaume Melquiond <guillaume.melquiond@gmail.com>
diff --git a/data/test.lua b/data/test.lua
index d419b9f..5252b82 100644
--- a/data/test.lua
+++ b/data/test.lua
@@ -14,8 +14,8 @@ function do_message(npc, ch, msg)
coroutine.yield(1)
end
-function do_choice(npc, ch, msg)
- tmw.msg_npc_choice(npc, ch, msg)
+function do_choice(npc, ch, ...)
+ tmw.msg_npc_choice(npc, ch, ...)
return coroutine.yield(2)
end
@@ -107,7 +107,7 @@ function my_npc1(npc, ch)
do_message(npc, ch, "Hello! I am the testing NPC")
do_message(npc, ch, "This message is just here for testing intertwined connections.")
do_message(npc, ch, "What do you want?")
- local v = do_choice(npc, ch, "Guns! Lots of guns!:Nothing")
+ local v = do_choice(npc, ch, "Guns! Lots of guns!", "Nothing.")
if v == 1 then
do_message(npc, ch, "Sorry, this is a heroic-fantasy game, I do not have any gun.")
end
@@ -127,10 +127,10 @@ end
function my_npc4(npc, ch)
do_message(npc, ch, "Where do you want to go?")
- local v = do_choice(npc, ch, "Map 1:Map 3")
+ local v = do_choice(npc, ch, "Map 1", "Map 3")
if v >= 1 and v <= 2 then
do_message(npc, ch, "Are you really sure?")
- local w = do_choice(npc, ch, "Yes, I am.:I still have a few things to do around here.")
+ local w = do_choice(npc, ch, "Yes, I am.", "I still have a few things to do around here.")
if w == 1 then
if v == 1 then
tmw.chr_warp(ch, nil, 60 * 32, 50 * 32)
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 3ed5ca9..fd3eb4f 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -118,16 +118,23 @@ static int LuaMsg_NpcChoice(lua_State *s)
{
NPC *p = getNPC(s, 1);
Character *q = getCharacter(s, 2);
- size_t l;
- char const *m = lua_tolstring(s, 3, &l);
- if (!p || !q || !m)
+ if (!p || !q)
{
LOG_WARN("LuaMsg_NpcChoice called with incorrect parameters.");
return 0;
}
MessageOut msg(GPMSG_NPC_CHOICE);
msg.writeShort(p->getPublicID());
- msg.writeString(std::string(m), l);
+ for (int i = 3, i_end = lua_gettop(s); i <= i_end; ++i)
+ {
+ char const *m = lua_tostring(s, i);
+ if (!m)
+ {
+ LOG_WARN("LuaMsg_NpcChoice called with incorrect parameters.");
+ return 0;
+ }
+ msg.writeString(m);
+ }
gameHandler->sendTo(q, msg);
return 0;
}