alias wait?

Posted by Wishsong on Fri 07 Sep 2007 05:11 AM — 3 posts, 19,904 views.

#0
the link at.
http://www.gammon.com.au/forum/?id=4956

tells me that you can add pauses in alias, and you say as much as that, you can wait for a specific line of text before waiting the required time and then executing your command
can you give me an example of how to do this?
i would want it to be something like.

<aliases>
<alias
match="l *"
enabled="y"
send_to="12"
sequence="100"
>
<send>Send("open door")
DoAfter (1, "turn on light")
wait for text "the light is now active"
DoAfter (2, "kill %1")</send>
</alias>
</aliases>

The command would first wait to receive the light is now active and then wait two seconds after which it will kill whatever..
thanks
Jack
USA #1
This thread has some info on waiting for certain messages from the mud, before continuing...

http://www.gammon.com.au/forum/?id=4957

I, myself have never used ANY coroutine, or anything related to it, I worked around it by having series of triggers that should fire one after another, because I just simply have refused to have a script file for my worlds, but am thinking I might just have to start for a particular mud I play on.

-Onoitsu2
Australia Forum Administrator #2
You don't need a script file. Based on what was in that thread (and reading the wait.lua file), this should work for you:


<aliases>
  <alias
   match="l *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"
wait.make (function ()
  Send ("open door")
  wait.time (1)  -- wait one second
  Send ("turn on light")
  wait.match ("the light is now active")  -- wait for text
  wait.time (1) -- wait one second
  Send ("kill %1")
end) 

</send>
  </alias>
</aliases>


Make sure you get the capitalization right for the message "the light is now active" - it has to match exactly.

The only problem with the above is that if the message "the light is now active" does not arrive, the alias pauses indefinitely waiting for it.

The version below uses a timeout of 5 seconds, to notify you and abort the operation:


<aliases>
  <alias
   match="l *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"
wait.make (function ()
  Send ("open door")
  wait.time (1)
  Send ("turn on light")
  ok = wait.match ("the light is now active", 5)
  if not ok then
    ColourNote ("white", "red", "Light did not turn on after 5 seconds")
    return
  end -- light timed out
  wait.time (1)
  Send ("kill %1")
end) 

</send>
  </alias>
</aliases>