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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  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] Refresh page


Posted by Etsuko   (1 post)  [Biography] 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?
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] 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>




Template:pasting 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
[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.


1,627 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 HostDash]