Creating an alias from an alias

by Unknown

Back to Mechanic's Corner.

Unknown2007-09-02 20:59:56
I actually have a couple of questions. I'm running on Vista, and zMUD apparently uses WinHelp (I haven't bothered downloading a viewer for it), so I can't see any of the zMUD help.

I'm working on creating an alias from within an alias. This is going to be used for a distributed offense system for my guild. Basically, I want to create something like this:

#alias addform {#IF (%null(%1) OR (%null(%2))) {#ECHO Correct syntax is: ADDFORM
} {
#ALIAS %2 {
#if (!%null( -- First parameter passed in to this alias --)) {
#var ToPerform @target
#loop ( -- First parameter passed in to this alias --) {#add ToPerform %1}
#execute {kata perform @ToPerform}
}
}
#ADDKEY Forms %1 %2
}
}

In the code above, I create an alias called whatever they pass in to %2. In the cases where I just put %1 and %2 within the alias above, I want to pass in the first and second parameters of the addform alias - this works by default. In the places where I put "-- First parameter passed in to this alias --" I would like to replace that with a literal %1, so that it uses the parameter passed into the NEW alias, instead of the %1 parameter passed into the addform alias.

Does anyone know if this is possible, or how it might be done?
Unknown2007-09-03 00:42:17
%%1 and %%2 should work.
Unknown2007-09-03 18:03:39
QUOTE(Zarquan @ Sep 2 2007, 07:42 PM) 438184
%%1 and %%2 should work.


I tried this:

#if (%null( %1) OR %null( %2)) {i_alert SYNTAX: addform } {
#alias %2 {
#if (!%null( %%1)) {
#var ToPerform @target
#loop %%1 {#add ToPerform %2}
#execute {kata perform @ToPerform}
}
}
#addkey Forms %1 %2
}

In the resulting alias %%1 was just replaced with a blank space. I also tried this instead:

#if (%null( %1) OR %null( %2)) {i_alert SYNTAX: addform } {
#alias %2 {
#if (!%null( ~%1)) {
#var ToPerform @target
#loop ~%1 {#add ToPerform %2}
#execute {kata perform @ToPerform}
}
}
#addkey Forms %1 %2
}

In this case, the new alias was created, but the value in it only had "{#if "

Any ideas what I'm doing wrong?
Drathys2007-09-04 05:07:50
It appears that %%1 doesn't work inside an #if block.

It works if you remove the outer #if.
#alias %2 {
#if (!%null( %%1)) {
#var ToPerform @target
#loop %%1 {#add ToPerform %2}
#execute {kata perform @ToPerform}
}
}

creates the correct alias:
#if (!%null( %1)) {
#var ToPerform @target
#loop %1 {#add ToPerform kk}
#execute {kata perform @ToPerform}
}
Unknown2007-09-04 13:39:34
QUOTE(Drathys @ Sep 4 2007, 12:07 AM) 438566
It appears that %%1 doesn't work inside an #if block.

It works if you remove the outer #if.
#alias %2 {
#if (!%null( %%1)) {
#var ToPerform @target
#loop %%1 {#add ToPerform %2}
#execute {kata perform @ToPerform}
}
}

creates the correct alias:
#if (!%null( %1)) {
#var ToPerform @target
#loop %1 {#add ToPerform kk}
#execute {kata perform @ToPerform}
}


Interesting...

I can work around the if block to make it work. Thanks!