[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  How to make an alias that pauses and loops
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

How to make an alias that pauses and loops

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


Posted by Ryanorion   (2 posts)  [Biography] bio
Date Fri 22 Feb 2008 10:11 PM (UTC)
Message
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
[Go to top] top

Posted by Nick Gammon   Australia  (21,675 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 23 Feb 2008 01:06 AM (UTC)
Message
Have you read http://mushclient.com/faq point 25?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Ryanorion   (2 posts)  [Biography] bio
Date Reply #2 on Sat 23 Feb 2008 07:11 PM (UTC)
Message
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
[Go to top] top

Posted by Nick Gammon   Australia  (21,675 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sat 23 Feb 2008 07:49 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


3,046 views.

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

Go to topic:           Search the forum


[Go to top] 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.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]