stacking commands within a speedwalk

Posted by Bainzr on Sun 16 Feb 2020 12:02 AM — 4 posts, 16,780 views.

#0
I have several long (800 or so) line alias that send with "speedwalk delay" of 2800 ms. I am trying to find a way to stack commands within that, as I need the speedwalk delay for about half of the commands but every second line i can send immediately after the line before it. This would allow me to cut my time in nearly half.

When I try to use the default stacking separator ; within the speedwalk it sends "command1; command2" to the world, and it doesn't process properly. If I send from the command line the same "command1; command2" it works as I want it do. suggestions?
Australia Forum Administrator #1
So, 37.3 minutes later the alias finishes, eh? Are you playing the game or running on automatic while you go shopping?

You can do that with a bit of scripting. This is one way, see below.


<aliases>
  <alias
   match="test"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"

things_I_want_to_do = {
  "strut self",
  "dance",
  "groan ; smile ; boggle",
  "look",
-- and so on
  } -- end of things to do

wait.make (function ()
  stop = false
  for _, item in ipairs (things_I_want_to_do) do
    if stop then
      break
    end -- if stopping wanted

    Execute (item)
    wait.time (1.8)
  end -- for

end)  -- end of anonymous function

</send>
  </alias>
</aliases>



Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.



That has a table of the things you want to send (so put your 800 lines there).

It also checks for a "stop" variable, in case you happen to want to stop doing whatever-it-is you are doing before the 37 minutes are up.

A "stop" alias sets that variable:


<aliases>
  <alias
   match="stop"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

  stop = true

  </send>
  </alias>
</aliases>






If you don't want to convert your 800 lines into a table you could put a long string into the script and read it line by line, like this:


<aliases>
  <alias
   match="test"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"
require "getlines"

-- big string of things to be sent, use command stacking if necessary

things_I_want_to_do = [[
strut self
dance
groan ; smile ; boggle
look
]] -- end of things to do

-- function to do pauses in scripts

wait.make (function ()
  stop = false
  for line in getlines (things_I_want_to_do) do
    if stop then
      break
    end -- if stopping wanted

    Execute (line)
    wait.time (1.8)  -- wait 1.8 seconds
  end -- for

end)  -- end of anonymous function

</send>
  </alias>
</aliases>


Sending to "Execute" invokes the command processor, which therefore does command stacking.




See http://www.gammon.com.au/forum/?id=4956 for the background about building pauses into scripts.
Amended on Sun 16 Feb 2020 06:04 AM by Nick Gammon
#2
thank you for the reply! I will look into that. But I was actually able to get what I needed with "\n". "command1 \n command2" works perfect. Any reason not to use it that way?
Australia Forum Administrator #3
No, I'd forgotten that would work.

My method allows you to interrupt the lengthy alias if you happen to need to, however.