Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ alias wait?

alias wait?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Wishsong   (2 posts)  Bio
Date Fri 07 Sep 2007 05:11 AM (UTC)
Message
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
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #1 on Fri 07 Sep 2007 07:22 AM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #2 on Sat 08 Sep 2007 01:06 AM (UTC)

Amended on Sat 08 Sep 2007 01:08 AM (UTC) by Nick Gammon

Message
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>


- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


15,239 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.