Help with aliases

Posted by Unregistered user on Mon 04 Dec 2000 12:00 AM — 18 posts, 64,221 views.

#0
I want to have a setup where I can type something like
"tank Borixanon"
then that sets the tank variable to borixanon and I could use macro keys to do different things to that variable
for example F1 could send "cast 'full heal' Borixanon"
and F2 could be "glance Borixanon"
I had a setup similar to this when I used ZMUD, something
to do with making a variable like @tank then you could just
set the macro to "cast 'full heal' @tank", ang change the variable by typing tank <whatever>
I don't know how to do this is MUSHClient but I think it
involves VBScript?
Would appreciate some help

- borixanon
Australia Forum Administrator #1
You can do this by expanding variables on an alias (this is an option when adding an alias). Here is what the help file has to say about it:

Expand Variables

If expand variables is on (checked) then a variable name in the format @name is expanded. To put a @ symbol itself n the alias, use two @@.

Here is an example of such an alias:




give @weapon to @person 




For this alias to work you would need two variables, "weapon" and "person".

You can set variables by using the configuration dialog box, or through a scripting command (if scripting is enabled), like this:



/world.setvariable "weapon", "harpoon" 



You could speed up setting the variable name by using another alias to do that. For example, you might have one alias called "sv" to Set Variable. It might look like this:



 
Alias: sv * 
Label: alias_sv 
Script: OnAliasSV 




Now put this in the script file:




sub OnAliasSV (thename, theoutput, thewildcards) 
world.setvariable "victim", thewildcards (1) 
world.note "Victim set to " & thewildcards (1) 
end sub 




Then your other aliases can use the "victim" variable, like this:



 
Alias: k 
Send: kick @victim 
Expand variables: yes 




The above alias would let you type "k" to kick the current victim. You could set up others to do similar things, or have a multi-line alias that sent various things at once.

Hope this helps.

- Nick
#2
ok so i make a variable weapon then expand it.
what should i send to the mud for that variable?
how do i let it know what i want inside @weapon?

- borixanon
Australia Forum Administrator #3
I'm not sure I understand the question. To send the *contents* of "weapon" you put an "@" in front of it, like this (inside an alias or trigger):



 
give @weapon to @person 





To change the type of weapon, type this into the command window:


 
/world.setvariable "weapon", "harpoon" 


#4
ok i have a variable named "target"
pretend this is the alias window

Alias: target
Send:


down here i have expanded variables enabled

what do i put in the "Send:" part?

i want to be able to do something like this
i type "target Dwarf"
then somewhere, somehow, it sets @target to "Dwarf"
then i have another alias called "bb", which sends
"backstab @target", with @target being Dwarf or whatever
i set it to.
so i can just change my target on the fly on go about
backstabbing things as quickly as possible




Australia Forum Administrator #5
OK, I see.

For the "target" alias I would do this:



 
Alias: target *
Send:  (leave blank)
Enabled: checked
All other options: unchecked
Label: Target_Alias
Script: OnAliasTarget




The above sets up an alias that responds to:



target Dwarf



The word "Dwarf" is the wildcard, represented by the asterisk.

It calls a script subroutine, that you need to put into the script file, like this:



 
sub OnAliasTarget (thename, theoutput, thewildcards) 
  world.setvariable "target", thewildcards (1) 
  world.note "Victim set to " & thewildcards (1) 
end sub 




This sets the variable "target" to the contents of wildcard #1 (in this case, "Dwarf").

Then make another alias, bb like this:




Alias: bb
Send:  backstab @target
Enabled: checked
Expand variables: checked
All other options: unchecked




Now when you type "bb" it will call the alias "bb" that sends "backstab @target", however it expands out "@target" as the contents of "target" variable, so it will really send "backstab Dwarf".

#6
i can almost achieve what i want by doing this:
making a variable called "target" and expanding it
making a variable called "targ *" that sends
/world.setvariable "target", "%1" to the mud
but the mud is reading /world.setvariable "target", "%1"
as a command to the mud rather than a command to mushclient

- borixanon
Australia Forum Administrator #7
Yes, that will happen. When an alias is expanded it merely sends the results to the MUD, it doesn't interpret them as a command.

You need to use the script that I described to achieve this effect.

MUSHclient evaluates commands that you type in a specific sequence:

1. Translate special escape sequences, if enabled (eg. \n).

2. If auto-say is enabled interpret the whole line as something "said" (unless the auto-say disable prefix is present).

3. Check for the script prefix (usually "/") and if so, interpret the rest of the line as a script command.

4. Handle command-stacking (break up lines at the ";" character, or whatever the command-stack character is).

5. Do speed-walking for each line, if the speed-walk prefix is present.

6. Replace each alias with the alias substitution string

7. Execute alias scripts


Because of this sequence, it does not re-interpret the results of an alias as a possible script (ie. step 6 does not repeat step 3).

If it did, you could make an alias (eg. "foo") that sent itself (eg. send "foo") which would then send MUSHclient into a loop, as it would keep re-evaluating the same alias.

#8
nick:
cuts down on my time a lot, helps out my game
been trying to figure that out awhile
again, thanks for the time you spend on the client
and answering questions
appreciate it mucho
later

- borixanon
#9
In theory ( i haven't tested it yet cause i'm at work) ok that does almost everything i want, I set an alias so everytime I type l b it sends "cast 'lightning bolt' @target" (target=dwarf)....but if I'm already in a melee combat i want to be able to type l b and I want it to send "cast 'lightning bolt'" because it auto targets the person i'm in melee with, so if I reset target to nothing, will it give a null error when it tries to send the variable 'target' which is equal to "" in string terms...oh never mind I guess I could just make target equal 1 space to solve that problem....nevermind I'm daft

Australia Forum Administrator #10
There is no problem with a variable being empty, as long as it exists.
#11
so whats a good FAST way to empty the variable
Australia Forum Administrator #12
Do you mean quick to type, or quick to execute?

A quick way which doesn't involve any setting up, would be to type:

/world.setvariable "myvariable", ""


However if you want to do that often, you could make an alias that calls a small script that does the same thing:

sub myalias (a, b, c)
world.setvariable "myvariable", ""
end sub

#13
Ok i swear i have done exactly that, when I type target dwarf sends a blank line to the world ( i think its printing it in black and the background is black, so how do you send to world in white or yellow in a script?) i think that part works though, then when i type k to kill dwarf it says Variable 'target' is not defined...i can't figure it out
Australia Forum Administrator #14
To do a colour note, do this:

world.colournote "white", "red", "my message"

Check your "variables" configuration window if you aren't sure what is happening with them (it is under the scripts item).
#15
ok this is messed, the variables section is blank...when i type that alias it runs this script

when i type target it does the alias
target *
which fires this script

sub OnAliasTarget (thename, theoutput, thewildcards)
world.setvariable "target", thewildcards (1)
world.note "white", "red", "Victim set to " & thewildcards (1)
end sub

(I tried it without the colors too)

it sends blank line to the mud, then when I type k it sends kill @target

this does not work....I have no idea why i can't get this to work, its driving me crazy, and i've re-done your exact steps multiple times....i have version 3.04 if that means anything...i know its something simple, but i'm going insane...
:)
Australia Forum Administrator #16
First, it is world.colournote if you are supplying colours.

Second, for the "k" alias do you have "expand variables" checked? If not, it will just send @target, not what target contains.

Check in the variables configuration window to see if the variable "target" has been correctly set up.

You might want to download a later version, we are up to 3.32, the earlier version might have a bug in that area.
#17
well you were right, there was a bug with that version...i downloaded the new version and it solved the problem...thanks! it was driving me nuts....