|
Chris_3413 Novice
Joined: 22 Mar 2004 Posts: 46 Location: Australia
|
Posted: Tue Nov 07, 2006 11:54 am
[1.13] %1 issue in aliases |
Ive just come across a very annoying issue.
I use a lot of aliases as shortcuts to using various channels.
as an example:
#ALIAS sra {clt2 %1}
Now, zMud would capture a full sentence and store it as %1 which would then be sent to the mud following the clt2 (which would send whatever text I typed to the channel of the clan listed in position 2 on my mud, which is Achaea)
cMud only seems to store the first word into %1 making my system of channel aliases unusable.
Theres probably some simple solution to this but its late at night and my mind isnt working well. |
|
_________________ What do you mean, Fatal Error! |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Tue Nov 07, 2006 2:09 pm |
#ALIAS sra {clt2 %-1}
|
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Tue Nov 07, 2006 4:18 pm |
zMUD never used to store the whole line as %1 when you used an alias. It just used to send all the alias parameters to the mud (or to the next alias).
%-1 is the syntax for all parameters, and this is the same as in zMUD. |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Tue Nov 07, 2006 5:40 pm |
That's a good point you make about the unused arguments being passed on through in zMUD, though. This isn't the way it should be in CMUD then? I mean, the alias was coded "incorrectly" but it worked because the %2..%nn arguments were just tacked on and sent to the MUD. If this behavior is changed in CMUD, people will need to know.
|
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Tue Nov 07, 2006 8:06 pm |
The behaviour is changed, and it is documented in the #alias command help:
Quote: |
Change from zMUD: In zMUD, any text following the aliasname that is not used as a parameter was appended to the results of the alias expansion. In CMUD this is not done automatically. To append parameters you must use the %params function to add the unused parameters. |
It should also be in the Changes for zMUD users section of the manual though. I'll add a comment. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Nov 07, 2006 9:16 pm |
Actually, I'm planning to add a option checkbox to aliases to allow the auto-append of text to aliases. This seems to be one of the bigger changes that I'm getting a lot of email about. I really wanted people to change their scripts to make them more obvious, but I think I'm going to be forced to add a compatibility option to cover this one.
|
|
|
|
Chris_3413 Novice
Joined: 22 Mar 2004 Posts: 46 Location: Australia
|
Posted: Wed Nov 08, 2006 1:25 pm |
Just shows I didnt really know HOW it worked.. I just knew it worked in a way that served the purpose I had in mind when I made it i'll try the %-1 thing and see what happens or maybe the new local variable features might do the trick also?
|
|
_________________ What do you mean, Fatal Error! |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Wed Nov 08, 2006 11:21 pm |
Local variables do not replace the %-1 syntax. Local variables can only each contain one value (or parameter), whereas %-1 contains all the parameters given to the alias. You also have %-2, etc. Check the documentation on aliases in either the zMUD manual or the CMUD manual.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Nov 08, 2006 11:27 pm |
Actually, you can use the named argument with the %params function. For example:
Code: |
#ALIAS test($arg1,$arg2) {#SHOW %params($arg1)} |
The %params function returns all parameters (arguments) starting and the specified one. The argument for %params can be either the number, or the named argument. So, the above %params($arg1) is the same as %params(1) which is also the same as %params. This same feature (named argument reference) is also implemented in the %param function, which just returns a single parameter. Although doing %param($arg1) would be a bit silly since that's the same as just doing $arg1
Anyway, using %params is a good way to make scripts a bit more readable, even though it makes the text longer.
But Seb is right..."local variables" are not the same thing as the "named arguments" here. Named Arguments are implemented as Local Variables (which is why $arg1 starts with a $ character like local variables), but named arguments have the special feature of working with the %param and %params functions. |
|
|
|
|
|