diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-20 12:20:42 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-20 12:20:42 +0000 |
commit | 518168ad7859ba214a79c48459e8053391339d68 (patch) | |
tree | 48bc672ce9804f6e1748304e4413e6f7b705bd1e /data/scripts | |
parent | 2e131bd3cbb2acb6ef52e7ad85f354ede543a392 (diff) | |
download | manaserv-518168ad7859ba214a79c48459e8053391339d68.tar.gz manaserv-518168ad7859ba214a79c48459e8053391339d68.tar.bz2 manaserv-518168ad7859ba214a79c48459e8053391339d68.tar.xz manaserv-518168ad7859ba214a79c48459e8053391339d68.zip |
Removed useless function prefixes. Commented Lua internal variables.
Diffstat (limited to 'data/scripts')
-rw-r--r-- | data/scripts/libtmw.lua | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/data/scripts/libtmw.lua b/data/scripts/libtmw.lua index 5fc894e8..bb724799 100644 --- a/data/scripts/libtmw.lua +++ b/data/scripts/libtmw.lua @@ -2,15 +2,28 @@ -- Support code -- ------------------ +-- Table that associates to each NPC pointer the handler function that is +-- called when a player starts talking to an NPC. local npcs = {} + +-- Table that associates to each Character pointer its state with respect to +-- NPCs (only one at a time). A state is an array with four fields: +-- . 1: pointer of the NPC the player is currently talking to. +-- . 2: coroutine running the NPC handler. +-- . 3: next query the NPC expects from a player (1 = next, 2 = choice). +-- . 4: countdown (in minutes) before the state is deleted. local states = {} + +-- Array containing the function registered by atinit. local init_fun = {} + +-- Tick timer used during update to clean obsolete states. local timer -- Creates an NPC and associates the given handler. -- Note: Cannot be called until map initialization has started. function create_npc(id, x, y, handler) - local npc = tmw.obj_create_npc(id, x, y) + local npc = tmw.npc_create(id, x, y) npcs[npc] = handler end @@ -19,7 +32,7 @@ end function do_message(npc, ch, msg) -- Wait for the arrival of a pending acknowledgment, if any. coroutine.yield(0) - tmw.msg_npc_message(npc, ch, msg) + tmw.npc_message(npc, ch, msg) -- An acknowledgment is pending, but do not wait for its arrival. coroutine.yield(1) end @@ -28,7 +41,7 @@ end function do_choice(npc, ch, ...) -- Wait for the arrival of a pending acknowledgment, if any. coroutine.yield(0) - tmw.msg_npc_choice(npc, ch, ...) + tmw.npc_choice(npc, ch, ...) -- Wait for player choice. return coroutine.yield(2) end |