Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Atvar
Newbie


Joined: 20 Apr 2012
Posts: 3

PostPosted: 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.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Atvar
Newbie


Joined: 20 Apr 2012
Posts: 3

PostPosted: 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.
Reply with quote
Atvar
Newbie


Joined: 20 Apr 2012
Posts: 3

PostPosted: Fri Apr 20, 2012 8:00 am   
 
Ok I got it, I simply declared a local variable which automatically expands in the alias command.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Apr 20, 2012 1:52 pm   
 
A global variable (with @) will also automatically expand in the alias command.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: 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, "}")}

Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: 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".
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net