|
Stevestones01 Beginner
Joined: 25 May 2010 Posts: 14
|
Posted: 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
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...
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? |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: 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 |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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 |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: 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 |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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. |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: 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 |
|
|
|
Stevestones01 Beginner
Joined: 25 May 2010 Posts: 14
|
Posted: 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
|
|
|
|
|
|