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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sun Mar 15, 2009 12:58 am   

Pattern Expressions
 
If I wanted to use a variable in a Pattern Expression, would I simply put @var_name in the pattern box, or do I need to select an option?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Mar 15, 2009 1:55 am   
 
What do you mean by "pattern expression"? Do you mean a trigger whose type has been set to "expression" rather than "pattern"? If that's the case, than whatever's in the Pattern box of the trigger will be evaluated as an expression - you'll have to decide for yourself whether or not using your variable that way makes sense in the context of what you want it to do. You could think of an expression trigger like an #if command:

#if (pattern here) {script here}

that's checked every time any of the variables in the pattern changes. If it makes sense to put your variable in an expression on its own, then you can do, but it's more likely you're going to want something like @var_name>250 or @var_name="cheese" in there.

If you didn't mean an expression trigger, then please explain what it is you're after.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sun Mar 15, 2009 6:15 pm   
 
Sorry, I was coining a term since I didn't know what the actual term was. To me, the Pattern Expression means it's allowed to have variables in the Pattern, but otherwise works like a normal pattern. It's not an expression, but it can have a variable like an expression can. Something like:

Pattern: <This is a @word>
where @word=prompt

so if you get
<This is a prompt>

from the MUD output, it matches and voila, the trigger has fired.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Mar 15, 2009 6:22 pm   
 
Don't coin terms without explaining what you mean, or nobody will know what you're on about :P

And yes, that'll work just fine. You could just try it and see :P
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sun Mar 15, 2009 9:25 pm   
 
Do note though you may notice some slowdown with that (depending on how often you call it, and how often the variable changes), because every time the variable changes the trigger pattern has to be recompiled.
_________________
Asati di tempari!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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