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
HaikuDan
Newbie


Joined: 20 Jul 2012
Posts: 2

PostPosted: Fri Jul 20, 2012 2:11 am   

Alias to create #SUB triggers
 
I'm trying to create an alias that creates #SUB triggers in a class and could use some help.

The format would be "AddID item [comment]" where I do want to include the square brackets. "item" can be variable length of alpha chars and white space.

A manually written out trigger that does what I want looks like this:
Code:
#TR {some pinkish colored pants} {#SUB {some pinkish colored pants [DEX+2 HP+5 Evil_only]}} {IDSubs}


So mud output:
Quote:
<worn on legs> some pinkish pants

Shows on my client as:
Quote:
<worn on legs> some pinkish pants [DEX+2 HP+5 Evil_only]


I'd like to create an alias to make it easier to add these subs, such as:
"AddID a shiny blue ring [INT+1 Para-1 DET_INVIS]" would expand to:
Code:
#TR {a shiny blue ring} {#SUB {a shiny blue ring [INT+1 Para-1 DET_INVIS]}} {IDSubs}


The thing I'm having trouble with is the pattern matching. I think I need a * because of the variable length of alpha chars and spaces, but I figure my square bracket should serve to delimit. I just don't know how to write the pattern match.

Any help would be appreciated.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Fri Jul 20, 2012 3:14 am   
 
Aliases don't use patterns. Are you trying to make a command input trigger? That would probably be the easiest way in this case anyway, the pattern would be something like this:
Code:
^addid (*) (~[*~])$


If you really want to use an alias, the easiest way to do it would be to use only one parameter (use %-1 to reference the first parameter and all others following it), and break it up using %match, with a similar pattern, to split the item and the comment. The only way to pass the item and comment to the alias as two parameters would be to use quotes on the command line (i.e. AddID "a shiny blue ring" "[INT+1 Para-1 DET_INVIS]"), which I think is less than ideal.
Reply with quote
HaikuDan
Newbie


Joined: 20 Jul 2012
Posts: 2

PostPosted: Fri Jul 20, 2012 4:02 am   
 
Thanks, I'll look into the help files for command input triggers, as I'm not familiar. Otherwise I will try it with quotes as you describe to do 2 parameters with the alias. Appreciate the input!
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Tue Jul 24, 2012 2:05 pm   
 
ugly.. but this works...

#CLASS {addID}
#ALIAS addid {
statsub = %-1
#EXECUTE {%char(35)TRIGGER %char(123)%expand(@statsub.1)%char(125) %char(123)%char(35)SUBSTITUTE %char(123)%expand(@statsub.1) [%expand(@statsub.2)]%char(125)%char(125) %char(123)addID%char(125)}
}
#VARIABLE stat_sub {}
#TRIGGER {some pinkish colored pants} {#SUBSTITUTE {shiny blue thing [DEX+2 HP+5 Evil_only]}}
#CLASS 0

left the trigger from example in the class...
#show ~<worn on legs~> some pinkish colored pants

yields:
<worn on legs> some pinkish colored pants [DEX+2 HP+5 Evil_only]



Syntax:
addid {the eq's description|stat+1 here+2}
addid {a shiny blue ring|INT+1 Para-1 DET_INVIS}

basically you are giving a string list on the command line and using the 2 parts to create the trigger.

zmud syntax check gripes if you remove all the %char(5) #, #char(123) {, and %char(125) } but it would still work and look prettier :P

trigger in alias without %chars... #EXECUTE {#TRIGGER {%expand(@statsub.1)} {#SUBSTITUTE {%expand(@statsub.1) [%expand(@statsub.2)]}} {addID}}
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