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
Stevestones01
Beginner


Joined: 25 May 2010
Posts: 14

PostPosted: Fri Jul 23, 2010 2:00 am   

Putting an alias in #send @variable
 
I have a variable called OnBalance, that I set to different things, such as:

Code:
OnBalance = {stand|smoke pipe with linseed|touch shield}


and then when I receive the message that I have regained balance I have it do

Code:
#send @OnBalance


This works great for most things, but occasionally there are a few times that I want to send an alias instead of just a simple list of commands. Is there a way to put the variable name in OnBalance, such as...

Code:
OnBalance = {stop}


where the alias stop is:

Code:
#ALIAS {stop} {stand;smoke pipe with linseed;touch shield}


Granted, this is a very simplistic one and doing it the longer way is just as good...but is it possible to do what I'm trying? Or am I just going to have to stick with doing it like the first example?
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Fri Jul 23, 2010 2:13 am   
 
Don't use #send, if its an alias it'll send the contents to the MUD anyways.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Jul 23, 2010 2:43 am   
 
However, ralgith, you DO need to use some sort of command as @OnBalance won't work by itself.

You could do something like:
Code:
#IF (%alias(@OnBalance)) {#EXEC @OnBalance} {#SEND @OnBalance}


I /think/ #EXEC will execute it as an alias, though I'm not 100% sure. Worth a shot, anyway.

Charneus
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Fri Jul 23, 2010 3:07 am   
 
He shouldn't have an alias embedded in a variable though was my point, just perform the alias straight up. And I know #EXEC will force an alias to fire, not sure about a var being used as an alias...

Just seems like we're over complicating things here... why not always use an alias? And just have the contents of the alias as colon delimited instead of pipe delimited like your vars are (which makes them string lists).
You could even go one better and do this:
#ALIAS stop {#FOREACH @OnBalance {#SEND %i}}
And such.

I just can't figure why you would try and use a variable as an alias when you can just use the alias directly.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Jul 23, 2010 12:21 pm   
 
Ralgith, using a variable to store the name of an alias to be executed later is perfectly fine. He can't just use the alias itself because this is a script to delay execution of an arbitrary set of commands, and sometimes those commands are aliases.

Yes, Charneus, your code should execute it as an alias. However, your code won't work if @OnBalance is a stringlist which contains an alias. Actually, it would not hurt to run #EXEC on things which are mud commands--it will send the code to the mud after determining whether it is an alias. But you need to either loop through the stringlist and run #EXEC on each element, or run #EXEC on %expandlist(@OnBalance,";"), so that it will execute the entire set of commands.
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Fri Jul 23, 2010 1:53 pm   
 
Ok, I get it, he wants MULTIPLE things in the variable, some aliases some not, and execute them all?
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Stevestones01
Beginner


Joined: 25 May 2010
Posts: 14

PostPosted: Sun Jul 25, 2010 5:02 am   
 
well, as of right now I only really have simple things that I could just put with #Send, but ya... my question was if it was possible to have a variable that has normal commands like stand, or sit, simple things, and also have aliases that have more complex things and have it execute the aliases as aliases...which the #exec worked perfect for. I don't need to use it yet, but I've been wondering if it was possible for ages. So I appreciate all the answers with this and sorry if I wasn't more clear with the question
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