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
➜ Pulling from an external file.
|
Pulling from an external file.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| BenTrafford
(2 posts) Bio
|
| Date
| Tue 03 Aug 2010 12:10 PM (UTC) |
| Message
| I'm guessing someone has done this, so I'm being lazy and hoping to save some time.
I've got a file. In this file, there is one MUSH command to each line. I'd like to open the file; go through the lines, one by one, pausing between each command to let it execute.
Does anybody have any code they'd care to share? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Tue 03 Aug 2010 09:11 PM (UTC) |
| Message
| For a start, under the Input menu there is an option "Send File" - that lets you send a disk file to the MUD.
However assuming you want to do this often in response to an alias (or some other reason) the aliases below will do it:
<aliases>
<alias
match="com"
enabled="y"
send_to="12"
sequence="100"
>
<send>
require "wait"
stop_sending = false
wait.make ( function ()
for line in io.lines (GetInfo (56) .. "commands.txt") do
if line ~= "" then
Send (line)
wait.time (0.5)
end -- if
if stop_sending then
return
end -- if
end
ColourNote ("cyan", "", "Sending file complete.")
end ) -- end wait.make function
</send>
</alias>
<alias
match="stop_com"
enabled="y"
send_to="12"
sequence="100"
>
<send>
stop_sending = true
ColourNote ("cyan", "", "Stopped sending file.")
</send>
</alias>
</aliases>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
The first one reads in the file "commands.txt" in the MUSHclient installation directory (change as required) and then sends each line to the MUD, with a 0.5 second pause. Change the 0.5 to whatever you want.
It also tests a "stop_sending" variable (which it initially clears). This lets the second alias be used to stop the sending. For example, if the file takes a couple of minutes to slowly send, and you change your mind, type "stop_com" to stop the sending process.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| BenTrafford
(2 posts) Bio
|
| Date
| Reply #2 on Wed 04 Aug 2010 01:21 PM (UTC) |
| Message
| | That worked! Thanks a bunch, Nick! | | 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.
13,635 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top