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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
darkspot
Apprentice


Joined: 29 Jul 2002
Posts: 105

PostPosted: Sun Jul 18, 2004 11:46 pm   

If statements, or another way to do an alias.
 
Basically I like making aliases/triggers as compact as possible and like to avoid having 20 alises if there's a way to make one serve this purpose.
The alias I'd like to make would do this...
I type "I Something"
it will check if the something is any of a list of things.. if it's one of a list, it will do something set to the list for that item. if it's not on the list, whatever was typed will just happen
Here's what I have so far for the alias if you don't understand what I'm talking about

#alias i {#if (%1 = "cl") {invoke cure light};#if (%1 = "cm") {invoke cure moderate}}

The problem I've come across is if the something is not one of the "list" of items (cl/cm/etc I only listed two so it's a short example) I want it to "invoke Whatever" but without stacking the ifs by using the second set of brackets for the if not, (the list is well into 50ish things, and I'd not care to stack 50 or so if statements) If you understand, and have any clue how to help... any help would be greatly appreciate.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Mon Jul 19, 2004 2:44 am   
 
Perhaps you could use a record variable. Something like:
#ADDKEY InvokeCommands {cl} {cure light}
#ADDKEY InvokeCommands {cm} {cure moderate}
#ALIAS i {#IF (%iskey(@InvokeCommands,"%1")) {invoke %db(@InvokeCommands,"%1")} {invoke %1}}

The #ADDKEYs are only to establish the variable in the first place. You might find the Settings Editor easier to use to expand on it.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Jul 19, 2004 2:44 am   
 
Use a record instead of a list.

#ADDKEY spellabbrevs {cl} {cure light}
#ADDK spellabbrevs {cm} {cure moderate}
#AL i {invoke %if( %iskey( @spellabbrevs, %1), %db( @spellabbrevs, %1), %1)}
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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