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
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sat Apr 30, 2005 12:51 am   

Placing a variable in a class using regex pattern match?
 
Hopefully an easy answer to this...

I've started playing with regular expressions a little, but can't seem to place variables inside specific classes once they're matched.

Normally I'd have made a trigger:
Code:
#trigger {^You have (%d) out of (%d) health remaining.$} {#variable chealth {%1} {} "Standard|score";#variable mhealth {%2} {} "Standard|score"} "Standard|score"


But the regex equiv (I think) is:
Code:
#REGEX {^You have (?chealth:\d+) out of (?mhealth:\d+) health remaining\.$} {} "Standard|score"


So the top example places the variables into a specific class, whereas the lower example doesn't.

I tried without success to change the regex to the following:
Code:
#REGEX {^You have (?Standard|score|chealth:\d+) out of (?Standard|score|mhealth:\d+) health remaining\.$} {} "Standard|score"


Problem is that sometimes I get more than one variable with the same name if I'm opening and closing classes as I go, and trying to find a quick way of keeping things tidy

Thanks in advance.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Apr 30, 2005 4:47 am   
 
use #variable.
_________________
EDIT: I didn't like my old signature
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sat Apr 30, 2005 11:17 am   
 
So it's a no? ;)
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
hav
Wanderer


Joined: 05 Oct 2004
Posts: 61
Location: Riga, Latvia

PostPosted: Sat Apr 30, 2005 5:58 pm   
 
Create variable beforehand yourself in the appropriate class. Then use that second trigger. (?varname:\d+) works like a charm.
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Sun May 01, 2005 4:00 pm   
 
This might work,
Code:
(?\classname\subclassname\variablename:\d+)


A Regex equivalent of this,
Code:
#trigger {^You have (%d) out of (%d) health remaining.$} {#variable chealth {%1} {} "Standard|score";#variable mhealth {%2} {} "Standard|score"} "Standard|score"

is ...
Code:
#REGEX {^You have (\d+) out of (\d+) health remaining\.$} {#variable chealth {%1} {} "Standard|score";#variable mhealth {%2} {} "Standard|score"} "Standard|score"


A non-Regex equivalent of this,
Code:
#REGEX {^You have (?chealth:\d+) out of (?mhealth:\d+) health remaining\.$} {} "Standard|score"

is ...
Code:
#trigger {^You have &%d{chealth} out of &%d{mhealth} health remaining.$} {} "Standard|score"





MUD = Timewaster Wink
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