How to make an alias that pauses and loops

Posted by Ryanorion on Fri 22 Feb 2008 10:11 PM — 4 posts, 17,854 views.

#0
I've never composed a script for Mush before. I need to compose a very very simple script.

inputs a list of commands in to the MUD
pauses for 1 second
inputs another list of commands in to the MUD
pauses for 3 seconds

and repeats itself

Would be nice if I could turn it on and off with a macro key.


Please Help!!

Ryan
Australia Forum Administrator #1
Have you read http://mushclient.com/faq point 25?
#2
Thank you! That was very helpful. Have an input commnd there and a delay command. And have an alias to turn it on / start it.


Only two more questions:


How could I make it continuously repeat by itself?

How could I assin a macro key or alias to turn it off / stop it?

Ryan
Australia Forum Administrator #3
Well to repeat you can make a loop, like this:


<aliases>
  <alias
   match="start"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
SetVariable ("stopnow", "n")

require "wait"
wait.make (function ()

  repeat
    Send ("open bag")

    wait.time (1)
    Send ("get food bag")

    wait.time (2)
    Send ("eat food")

    wait.time (1)
    Send ("close bag")

  until GetVariable ("stopnow") == "y"

end) 
</send>
  </alias>
</aliases>


This example (which you invoke by typing "start") loops until the variable "stopnow" contains "y". It starts off by setting that variable to "n", so it will loop.

Next you need an alias to set the stopnow variable:


<aliases>
  <alias
   match="stop"
   enabled="y"
   variable="stopnow"
   send_to="9"
   sequence="100"
  >
  <send>y</send>
  </alias>
</aliases>


That will move "y" to stopnow, thus stopping the loop.