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
➜ General
➜ lua: sending a list of commands to a mud all while. a way to stop them mid way.
lua: sending a list of commands to a mud all while. a way to stop them mid way.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Etsuko
(1 post) Bio
|
Date
| Sat 06 Jan 2024 12:07 PM (UTC) |
Message
| hello everyone
I'm verry new to Mush client, and scripting. I wanted to ask a question. I want to do the following:
send a huge list of commands, with a delay in bitween each. and also an ability to stop the sequence if I send, lets say, stop. is this possible? | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 06 Jan 2024 04:09 PM (UTC) |
Message
| Certainly it's possible. One way is to use the techniques described here:
http://www.gammon.com.au/forum/?id=4956
That shows how you can script doing stuff with pauses between things. In that script you could test a variable, and use an alias to set a "stop" variable. If that variable is set then the script could exit.
The commands themselves could be in a Lua table, or a huge block of text which you read a line at a time. For doing that, see:
http://www.gammon.com.au/forum/?id=6544
Or, you might read a file, and put the commands in that. Then read the file a line at a time. For file handling, see:
http://www.gammon.com.au/scripts/doc.php?general=lua_io |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #2 on Sat 06 Jan 2024 04:16 PM (UTC) Amended on Sat 06 Jan 2024 04:24 PM (UTC) by Nick Gammon
|
Message
| Example code:
<aliases>
<alias
match="send_my_commands"
enabled="y"
send_to="12"
sequence="100"
>
<send>
require "wait"
wait.make (function ()
stopCommands = false -- variable to stop the loop
f = io.input ("commands.txt")
for line in f:lines () do
Send (line)
if stopCommands then
break
end
wait.time (1) -- wait a second
end
f:close () -- close that file now
end)
</send>
</alias>
<alias
match="stop_my_commands"
enabled="y"
send_to="12"
sequence="100"
>
<send>
stopCommands = true -- variable to stop the loop
Note "Command sending stopped"
</send>
</alias>
</aliases>
|
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
This would give you two aliases:
- send_my_commands - start sending the contents of the file commands.txt
- stop_my_commands - stop sending those commmands
I have put a one second delay between each command, you can change that, of course. |
- 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.
2,859 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top