summaryrefslogtreecommitdiffstats
path: root/data/scripts/libs/libtmw.lua
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-11-06 16:19:54 +0000
committerDavid Athay <ko2fan@gmail.com>2008-11-06 16:19:54 +0000
commit40897abf694eadda6d32929d7263114bf00acc11 (patch)
tree4fb088602f860a334749a7bff61927bb3cef4cb2 /data/scripts/libs/libtmw.lua
parent37a627f2e9d0de8d198f23cb363aacb1acf1f281 (diff)
Forgot the data files, sorry
Diffstat (limited to 'data/scripts/libs/libtmw.lua')
-rw-r--r--data/scripts/libs/libtmw.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/data/scripts/libs/libtmw.lua b/data/scripts/libs/libtmw.lua
index 4002a5a..4505d15 100644
--- a/data/scripts/libs/libtmw.lua
+++ b/data/scripts/libs/libtmw.lua
@@ -71,6 +71,14 @@ function do_choice(npc, ch, ...)
return coroutine.yield(2)
end
+-- Sends an NPC request to send letter to a player and waits for them to
+-- send the letter.
+function do_post(npc, ch)
+ coroutine.yield(0)
+ tmw.npc_post(npc, ch)
+ return coroutine.yield(1)
+end
+
-- Gets the value of a quest variable.
-- Calling this function while an acknowledment is pending is desirable, so
-- that lag cannot be perceived by the player.
@@ -182,6 +190,14 @@ function npc_choose(npc, ch, u)
end
end
+-- Called by the game when a player sends a letter.
+function npc_post(npc, ch, sender, letter)
+ local w = states[ch]
+ if not (w and w[1] == npc and w[3] == 1 and process_npc(w, sender, letter)) then
+ states[ch] = nil
+ end
+end
+
-- Called by the game whenever the value of a quest variable is known.
-- Checks that the NPC expects it, and processes the respective coroutine.
-- Note: the check for NPC correctness is missing, but it should never matter.