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


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, 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.
 Entire forum ➜ MUSHclient ➜ General ➜ command line grouping (alias help)

command line grouping (alias help)

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


Posted by SKYY   (28 posts)  Bio
Date Fri 18 Apr 2008 05:52 PM (UTC)
Message
I need to write some sort of alias that finds any command or commands that are input between curvy brackets {}, and that plays well with other plugins like multiple_send, for example.

For example, if I input this:

#12 {buy 20 heal;empty bag @container;drop bag}

I want the alias to send the following:

buy 20 heal
empty bag @container
drop bag
buy 20 heal
empty bag @container
drop bag
buy 20 heal
empty bag @container
drop bag
... (to 12)

I've tried messing with this before, but it's totally beyond my scripting capabilities thus far. Obviously, I already have the ";" character set to be my separator, but that doesn't particularly help this alias.

Any clue on where to start with this one?
Top

Posted by Nick Gammon   Australia  (23,046 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 19 Apr 2008 12:30 AM (UTC)
Message
See http://mushclient.com/faq point 47, which pretty much covers all that.

However the ideas there vary slightly from what you presented.

One complexity is in your example:


#12 {buy 20 heal;empty bag @container;drop bag}


Now if you have ';' as the command stack character, then the line you type is broken up *before* it goes to the alias. In other words, it will become:


#12 {buy 20 heal
empty bag @container
drop bag}


Now you can see this won't work properly, as none of those lines will make much sense. The plugin presented in the thread above (Repeat_Command.xml) will handle the command stacking alright, and it doesn't need the braces.

So you could type this:


;#12 buy 20 heal;empty bag @container;drop bag


Note the initial ';' which stops MUSHclient breaking up the line at the subsequent semicolons, and thus the whole line goes to the plugin, which then does everything 12 times.

Also note you don't need the braces.

Another approach is to turn command stacking off in the commands configuration, and let the plugin do it. To do that, change in the plugin the lines:


-- execute (send to command processor) the command
for i = 1, %1 do
  Execute "%2"
end -- for loop


to:


-- execute (send to command processor) the command
for i = 1, %1 do
  string.gsub ("%2", "[^;]+", Execute)
end -- for loop


What that does is break up the line at semicolons, and send each one to Execute (so aliases will be processed).

However for this to work you have to turn command stacking off. Then you could just type:


#12 buy 20 heal;empty bag @container;drop bag


This is the simplest, because you don't need a leading semicolon, and you don't need the braces around the commands.

- Nick Gammon

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

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #2 on Sat 19 Apr 2008 03:40 AM (UTC)
Message
I have long since used a loop alias, and have always just doubled the command stacking character, and it sends the command list to be 'executed'. In doing it this method i have even stacked loops within loops, so something like this.

loop 4 Command1;;Command2;;loop 3 Command3;Final Command Here

I have used this in many ways, grabbing items, dropping things, and even enchanting items.

You might try that method also.

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


14,719 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

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]