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


Joined: 29 Jan 2010
Posts: 5

PostPosted: Thu Feb 11, 2010 5:20 am   

How do I make two triggers on thing? (kind of like fallthrough)
 
I want too have two triggers setting of on same text. reason is i want too make some modularity changes in my code so i dont nest it all.

is this possible?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Feb 11, 2010 5:55 am   
 
#trigger {pattern} {one set of code}
#trigger {pattern} {a different set of code}

Is that what you're looking for?

You can also do it like this:

#trigger {pattern} {#raise some_event_name}
#event {some_event_name} {one set of code}
#event {some_event_name} {different set of code}
_________________
EDIT: I didn't like my old signature
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Feb 11, 2010 8:52 pm   
 
As Matt said, you can have as many triggers using the same pattern as you want. If you need to distinguish between them, for instance for enabling or disabling them separately, you can either put them into separate classes and control the classes, or give each one a unique id. This works perfectly well, especially if you only have a few triggers with the same pattern.

Using events, as in Matt's second option, is an even cleaner form of modularization. In the first option, with multiple triggers, cmud needs to test the pattern of _each_ trigger against each input line, which means a lot of extra work if you have many triggers with the same pattern. It probably wouldn't noticeably slow you down because cmud is so fast, but it can add up. Using events, you only need to test the pattern against the line once. Raising an event name causes every enabled event with that name to be executed.
Reply with quote
ashii
Newbie


Joined: 29 Jan 2010
Posts: 5

PostPosted: Fri Feb 12, 2010 7:59 pm   
 
thanks, i figured out too i had messed up my priorities =)
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