diff options
| author | David Athay <ko2fan@gmail.com> | 2008-10-24 15:18:02 +0000 |
|---|---|---|
| committer | David Athay <ko2fan@gmail.com> | 2008-10-24 15:18:02 +0000 |
| commit | 20fe6419f8d9564e7ab098ead53c6ef5da1519fa (patch) | |
| tree | 5313713cd9f12ca3fc503db2ceaccaa73f12a355 /data/scripts | |
| parent | ef9852cddecfc5abce38438ca2138defb1a9b1bf (diff) | |
Added post callback for getting post.
Added GM command for changing player attributes. Changed GM command to
@ as '/' was already being used by client for local commands.
Diffstat (limited to 'data/scripts')
| -rw-r--r-- | data/scripts/libs/libtmw.lua | 19 | ||||
| -rw-r--r-- | data/scripts/test.lua | 10 |
2 files changed, 29 insertions, 0 deletions
diff --git a/data/scripts/libs/libtmw.lua b/data/scripts/libs/libtmw.lua index 5df9e3c..251e20a 100644 --- a/data/scripts/libs/libtmw.lua +++ b/data/scripts/libs/libtmw.lua @@ -123,6 +123,12 @@ function get_quest_var(ch, name) return coroutine.yield(3, name) end +-- Gets the post for a user. +function getpost(ch) + tmw.chr_get_post(ch) + return coroutine.yield(3) +end + -- Processes as much of an NPC handler as possible. local function process_npc(w, ...) local co = w[2] @@ -234,6 +240,19 @@ function quest_reply(ch, name, value) states[ch] = nil end +function post_reply(ch, sender, letter) + local w = states[ch] + if w then + local w3 = w[3] + if (w3 == 3 or w3 == 4) then + if process_npc(w, sender, letter) then + return + end + end + end + states[ch] = nil +end + -- Called by the game every tick for each NPC. function npc_update(npc) local h = npc_update_functs[npc]; diff --git a/data/scripts/test.lua b/data/scripts/test.lua index d3cd14a..344ca10 100644 --- a/data/scripts/test.lua +++ b/data/scripts/test.lua @@ -187,4 +187,14 @@ function post_talk(npc, ch) do_message(npc, ch, "Hello " .. tmw.being_get_name(ch)) local strength = tmw.being_get_attribute(ch, ATTR_STRENGTH) do_message(npc, ch, "You have " .. tostring(strength) .. " strength") + do_message(npc, ch, "Would you like to see your mail?") + local answer = do_choice(npc, ch, "Yes", "No") + if answer == 1 then + local sender, post = getpost(ch) + if sender == "" then + do_message(npc, ch, "No Post right now, sorry") + else + do_message(npc, ch, tostring(sender) .. " sent you " .. tostring(post)) + end + end end |
