summaryrefslogtreecommitdiff
path: root/src/scripting/lua.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-07-12 14:02:36 -0600
committerJared Adams <jaxad0127@gmail.com>2009-07-12 14:02:36 -0600
commit80d8c865909b26d0e8a04dc86a34c084507e2bd3 (patch)
tree913e0a7631dd64fd0d730597a6e401b16447ab84 /src/scripting/lua.cpp
parent5d4d4534a9723ded7e76ce1f8c27765e8e86ca3d (diff)
downloadmanaserv-80d8c865909b26d0e8a04dc86a34c084507e2bd3.tar.gz
manaserv-80d8c865909b26d0e8a04dc86a34c084507e2bd3.tar.bz2
manaserv-80d8c865909b26d0e8a04dc86a34c084507e2bd3.tar.xz
manaserv-80d8c865909b26d0e8a04dc86a34c084507e2bd3.zip
Allow npc_choice to take tables of strings
Diffstat (limited to 'src/scripting/lua.cpp')
-rw-r--r--src/scripting/lua.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index f607d976..d5c12c76 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -98,13 +98,31 @@ static int npc_choice(lua_State *s)
msg.writeShort(p->getPublicID());
for (int i = 3, i_end = lua_gettop(s); i <= i_end; ++i)
{
- const char *m = lua_tostring(s, i);
- if (!m)
+ if (lua_isstring(s, i))
+ {
+ msg.writeString(lua_tostring(s, i));
+ }
+ else if (lua_istable(s, i))
+ {
+ lua_pushnil(s);
+ while (lua_next(s, i) != 0) {
+ if (lua_isstring(s, -1))
+ {
+ msg.writeString(lua_tostring(s, -1));
+ }
+ else
+ {
+ raiseScriptError(s, "npc_Choice called with incorrect parameters.");
+ return 0;
+ }
+ lua_pop(s, 1);
+ }
+ }
+ else
{
raiseScriptError(s, "npc_Choice called with incorrect parameters.");
return 0;
}
- msg.writeString(m);
}
gameHandler->sendTo(q, msg);
return 0;