![](templates/Classic/images/spacer.gif) |
Atvar Newbie
Joined: 20 Apr 2012 Posts: 3
|
Posted: Fri Apr 20, 2012 6:11 am
Alias / Variable question. |
This is probably pretty simple, but unable to figure this out from the documentation.
I want to create an alias using information that is currently within a variable, but I dont want the alias to refer directly to the variable itself.
E.G
#VAR A {123}
#ALIAS TEST {@A}
The variable @A may change at a later date, but I want the alias to take the value directly from @A. I'm guessing there is simply sometype of prefix symbol or something to evaluate it. |
|
|
![](templates/Classic/images/spacer.gif) |
shalimar GURU
![](images/avatars/114658559147aeed8fee539.gif)
Joined: 04 Aug 2002 Posts: 4717 Location: Pensacola, FL, USA
|
Posted: Fri Apr 20, 2012 6:54 am |
That is how basic variables work.
putting the @ symbol on a variableName will use the current value at the time the script is executed.
Your example, the test alias, tries to send '123' as a command to the MUD. |
|
_________________ Discord: Shalimarwildcat |
|
|
![](templates/Classic/images/spacer.gif) |
Atvar Newbie
Joined: 20 Apr 2012 Posts: 3
|
Posted: Fri Apr 20, 2012 7:12 am |
Yes, so how would you send it the value of the variable, as opposed to the reference to the variable.
Basically I want the value of the variable that it is right now, not what it will be in the future. |
|
|
![](templates/Classic/images/spacer.gif) |
Atvar Newbie
Joined: 20 Apr 2012 Posts: 3
|
Posted: Fri Apr 20, 2012 8:00 am |
Ok I got it, I simply declared a local variable which automatically expands in the alias command.
|
|
|
![](templates/Classic/images/spacer.gif) |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Fri Apr 20, 2012 1:52 pm |
A global variable (with @) will also automatically expand in the alias command.
|
|
|
![](templates/Classic/images/spacer.gif) |
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Fri Apr 20, 2012 2:21 pm |
There's no good way to do it off the command line, your best bet is making an alias in the package editor and typing in the current value manually. If you're trying to do it within a script, the only way is to do something like this:
Code: |
#EXEC {%concat( "#ALIAS TEST {", @A, "}")} |
|
|
|
![](templates/Classic/images/spacer.gif) |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Fri Apr 20, 2012 5:34 pm |
By the way, if you want the alias to actually send the value of the variable as a command to the mud, you should use #SEND. You should never start a command line with a variable (starting with @) or a function (starting with % or @), and the only time you should start a command line with a local variable (starting with $) is if you are setting the value of a local variable.
So, the alias should execute "#SEND @A" instead of "@A". |
|
|
![](templates/Classic/images/spacer.gif) |
|
|