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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ How to make an alias that pauses and loops
|
How to make an alias that pauses and loops
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Ryanorion
(2 posts) 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 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sat 23 Feb 2008 01:06 AM (UTC) |
| Message
| |
| Posted by
| Ryanorion
(2 posts) 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 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) 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 | | 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.
16,949 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top