Register forum user name Search FAQ

Gammon Forum

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 ➜ stacking commands within a speedwalk

stacking commands within a speedwalk

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Bainzr   (2 posts)  Bio
Date Sun 16 Feb 2020 12:02 AM (UTC)
Message
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?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 16 Feb 2020 05:59 AM (UTC)

Amended on Sun 16 Feb 2020 06:04 AM (UTC) by Nick Gammon

Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Bainzr   (2 posts)  Bio
Date Reply #2 on Mon 17 Feb 2020 01:23 AM (UTC)
Message
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?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 17 Feb 2020 05:12 AM (UTC)
Message
No, I'd forgotten that would work.

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

- 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,721 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.