Gammon Forum
Entire forum
MUSHclient
General
A question about wait.lua.
A question about wait.lua.
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Lzkd
(28 posts) bio
|
Date
| Fri 21 Nov 2014 12:13 PM (UTC) |
Message
| Hello everyone
I have used DoAfter before.Later found wait.lua.Find it very interesting.But I was not good.
So, I ask, can you give me some tutorials, or link.Let me study.
Thank you again. | top |
|
Posted by
| Fiendish
USA (2,514 posts) bio
Global Moderator |
Date
| Reply #1 on Fri 21 Nov 2014 04:11 PM (UTC) Amended on Fri 21 Nov 2014 04:28 PM (UTC) by Fiendish
|
Message
| All of the details for what is going on with wait.lua are in
http://www.gammon.com.au/forum/?id=4956
and
http://www.gammon.com.au/forum/?id=4957
The short version is:
wait.lua does two things.
The first is that it adds a convenience layer on top of DoAfterSpecial ( http://www.gammon.com.au/scripts/function.php?name=DoAfterSpecial ).
The following codes do the same thing, but the second one is much easier to understand:
function do_some_things_with_pauses()
part_a()
end
function part_a()
print("this is part A!")
DoAfterSpecial(5, "part_b()", sendto.script) -- wait 5 seconds then call part B
end
function part_b()
print("this is part B!")
DoAfterSpecial(5, "part_c()", sendto.script) -- wait 5 seconds then call part C
end
function part_c()
print("this is part C!")
end
require "wait"
function do_some_things_with_pauses()
wait.make(function()
print("this is part A!")
wait.time(5)
print("this is part B!")
wait.time(5)
print("this is part C!")
end)
end
The second thing is that it adds a convenience layer on top of AddTriggerEx ( http://www.gammon.com.au/scripts/function.php?name=AddTriggerEx ).
The following code gives you similar readability as above, but with waiting for output from the game instead of for a set amount of time:
require "wait"
function do_some_things_with_waiting_for_responses()
wait.make(function()
print("when my game gets this next command it will respond with 'HELLO'")
Send("send me HELLO")
wait.match("HELLO") -- wait forever for the game to send HELLO
print("My game just responded with 'HELLO'!")
print("when my game gets this next command it will respond with 'GOODBYE'")
Send("send me GOODBYE")
wait.match("HELLO", 10) -- wait for up to 10 seconds for the game to send HELLO
print("10 seconds must have passed, because I was waiting for 'HELLO' but my game never sent it!")
end)
end
|
https://github.com/fiendish/aardwolfclientpackage | top |
|
Posted by
| Lzkd
(28 posts) bio
|
Date
| Reply #2 on Sat 22 Nov 2014 12:54 AM (UTC) |
Message
| Thank you very much. I go to study. | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
10,263 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.