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
➜ Help with aliases
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Unregistered user
(72 posts) Bio
|
Date
| Mon 04 Dec 2000 (UTC) |
Message
| 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 06 Jan 2001 (UTC) |
Message
| 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:
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 |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Unregistered user
(72 posts) Bio
|
Date
| Reply #2 on Fri 02 Feb 2001 (UTC) |
Message
| 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Fri 02 Feb 2001 08:32 AM (UTC) |
Message
| 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):
To change the type of weapon, type this into the command window:
/world.setvariable "weapon", "harpoon"
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Unregistered user
(72 posts) Bio
|
Date
| Reply #4 on Fri 02 Feb 2001 08:41 AM (UTC) |
Message
| 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
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Fri 02 Feb 2001 08:51 AM (UTC) |
Message
| 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".
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Unregistered user
(72 posts) Bio
|
Date
| Reply #6 on Fri 02 Feb 2001 08:56 AM (UTC) |
Message
| 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #7 on Fri 02 Feb 2001 09:10 AM (UTC) |
Message
| 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.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Unregistered user
(72 posts) Bio
|
Date
| Reply #8 on Fri 02 Feb 2001 09:23 AM (UTC) |
Message
| 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
| Top |
|
Posted by
| Brooster
(3 posts) Bio
|
Date
| Reply #9 on Wed 13 Nov 2002 04:47 PM (UTC) |
Message
| 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
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #10 on Wed 13 Nov 2002 08:22 PM (UTC) |
Message
| There is no problem with a variable being empty, as long as it exists. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Brooster
(3 posts) Bio
|
Date
| Reply #11 on Wed 13 Nov 2002 08:24 PM (UTC) |
Message
| so whats a good FAST way to empty the variable | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #12 on Wed 13 Nov 2002 09:09 PM (UTC) |
Message
| 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
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Brett McLennan
(9 posts) Bio
|
Date
| Reply #13 on Thu 14 Nov 2002 12:21 AM (UTC) |
Message
| 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #14 on Thu 14 Nov 2002 09:16 PM (UTC) |
Message
| 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). |
- 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.
46,264 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top