Macro Functions?

Posted by BartzS on Wed 23 Jun 2004 06:29 AM — 6 posts, 23,987 views.

#0
I used to use a Front-End that had these macro abilities:

\r = return anywhere in macro line
\p = pause 1 second at any point in macro line
\? = prompt window to enter text anywhere in macro line
@ = place cursor anywhere in macro line
\a = enters last attacked creature name anywhere in macro line
etc.

Can I do this stuff in MUSHClient? Is there a place I can go to look at macro features? The help file seemed to suggest you couldn't do any of this stuff which was kind of disappointing since they are very convenient features.

Thanks
Australia Forum Administrator #1
Not sure what you mean by some of these. "return anywhere"? "place cursor anywhere"? Why do you want to do that?

You can put wildcards into aliases, thus substituting text.

eg.

match: k *
send: kill %1


You can pause by using DoAfter, eg.

match: blah
send:

Send "drink potion 1"
DoAfter 1, "drink potion 2"

send to: script


Entering the "last attacked creature" - you have to tell it how to know what that is, generally by a trigger. eg. a trigger might be:

match: * attacks you
send: %1
send to: variable
variable: target

Then an alias might be:

match: a
send: attack @target
expand variables: checked

USA #2
I think for the "return anywhere" he was talking about multiple lines.

However, these "macros" sound more like full fledged script... things, as the entering text thing is kind of weird. So theyre not just simple aliases/triggers.

However, BartzS, yes you can do much of that stuff, if you could be more specific about what you want, we can help you more.
#3
Okay, more specifically (the actual documentation discussing the use of macro keys in this particular front-end)...

The special tokens you can use when creating macros are:

Press Enter ( \r )

The first token you can use is '\r', which tells the macro processor to "hit the enter key". For example, this macro would prepare you to go off to battle:
get sword from my sheath\rrem my shield\r
This macro would output

get sword from my sheath
<press the Enter key>
rem my shield
<press the Enter key>

Cursor Placement ( @ )

When you put the '@' character in a macro, it tells the macro processor to "put the cursor right here". For example, if you set up a macro like this to greet people:
whisper @ 'Hi! Nice to meet you!
the processor would

(a) place the text "whisper 'Hi! Nice to meet you!" in the input line area, and then
(b) position the cursor in between the words "whisper" and "'Hi! ". Then you would just key in the name and press the <Enter> key.

Prompt Me ( \? )

If you place any '\?' tokens in your macro, the macro processor will prompt you for a string to replace the \?'s with. For example, here is a macro I define as the Alt-G key (for 'G'et):
Get \?\rput \? in my backpack\r
When you hit the Alt-G key now, the program will prompt you for a string (let's say you key in "gem"), replace all occurrences of '\?' with "gem" and then output:

get gem <press Enter>
put gem in my backpack <press Enter>

Pause ( \p )

Placing a '\p' token in a macro will pause for 1 second. For example:
attack troll\r\p\p\pstance defensive\r
would:

attack troll <press Enter>
<pause 3 seconds>
stance defensive <press Enter>

Last Attacked ( \a )

This token will be replaced by the character last name

Short-cut keys:

Setting a macro key to one of the following strings will execute the following actions:

{magic} pops up the Magic Menu when you press that key.

{stance} pops up the Stance menu

{injuries} toggles the injury display between wounds/scars

{wounds} same as {injuries}

{cut} Since the Wizard totally takes over the keyboard

{copy} from Windows, these options allow you to assign

{paste} normal cut/copy/paste/clear actions for the

{clear} Windows clipboard.

{drag} shortcut to choosing "Drag/Drag Someone.." from the menu bar.

{rest}<action> puts you into "resting" mode. This is handy for when you have to step away from the computer for a while, but you don't want to be logged off. The Wizard will output an "experience" command every two minutes, followed by the action you have specified. For example:

{rest}act snores softly.
Would do the following every two minutes:

exper <press enter>
act snores softly.

{script} shortcut to choosing "Scripts/Execute a Script" from the menu bar.

{record} shortcut to choosing "Scripts/Record a Script" from the menu bar.

{=script.wiz} this shortcut will execute the script specified. For example, if you have a script named "prep.wiz" in your scripts directory that preps and casts all of your normal pre-hunting defensive spells, you could fire that off from a keypress by setting the key macro string to:

{=prep} (or {=prep.wiz})

(it's copywrited so please don't sue)
Australia Forum Administrator #4
Enter key

The put a newline into the text to be sent simply press Ctrl+Enter when typing in the macro or alias. You will see the linebreak in the "send" box on the screen and multiple lines will be sent.


Cursor placement

Sounds like this system is more interactive than MUSHclient's. In this case I would just use a wildcard. eg. To greet someone:


match: greet *
send: whisper %1 'Hi! Nice to meet you!


This saves the two-step process you describe. You simply type:


greet nick


and MUSHclient will send:


whisper nick 'Hi! Nice to meet you!



Prompt me

Again I would use a wildcard, but you can do the message box like this (copy and paste this into MUSHclient):


<aliases>
  <alias
   match="k"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>who = InputBox ("kill who ...", "MUSHclient")
if who &lt;&gt; "" then
  Send "Kill " &amp; who
end if</send>
  </alias>
</aliases>


What this does is use the InputBox script command to pop up a box, and then send the resulting text (with the word "kill" in this example) to the MUD.


Pauses

Do do a pause, make an alias like this:

match: at
send:

Send "attack troll"
DoAfter 3, "stance defensive"

send to: script

This sends "attack troll" now, and after 3 seconds, sends "stance defensive"


Rest mode

To do things every minute or two, you need to add a timer.

eg.

Every: 2 minutes
Send: act snores softly.
Label: rest

If you want to turn it on and off you can make an alias (eg. "rest") like this:


match: rest
send: EnableTimer "rest", 1
send to: script


And, another timer to cancel resting:


match: norest
send: EnableTimer "rest", 0
send to: script



The other things

Quote:

{magic} pops up the Magic Menu when you press that key.


I'm not sure all these are serious questions. MUSHclient doesn't have a Magic Menu, so you can't really have a key to display it.

However, all of the things that you can do from MUSHclient menus, you can also do from scripting by using DoCommand. See this page:


http://www.gammon.com.au/scripts/doc.php?function=DoCommand


For example:


DoCommand "copy"


would do the Copy menu item.




MUSHclient is different from your other program, but can do heaps of things. Rather than trying to do exactly what your other client does, in the same way, browse the help files, and read some of the earlier forum posts, to find people doing things similar to what you want.
Amended on Thu 24 Jun 2004 10:04 PM by Nick Gammon
#5
Thanks Nick. You're right, it's just a matter of learning how to do those things another way.