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
Josiah.Bruns
Apprentice


Joined: 04 Mar 2007
Posts: 103

PostPosted: Mon Oct 26, 2009 6:45 pm   

does anyone know if its ok to have 2 trigs with the same pattern.
 
i.e. when i get exp i have a loot trig.
but i also have a calculate exp per hour trig. and i like to have them seperate so i can enable and disable them as needed, without having to comment out code.

i have done it before and it has worked some times and seemed flaky at others. i wasn't sure if maybe you shouldn't do it or if its ok but i takes some tunning. i was curious if maybe the priority comes into play when your run into a senerio like this.

thanks for any help.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Oct 26, 2009 8:32 pm   
 
Yes, it is quite reasonable to do this in certain circumstances. To specify which one to enable or disable, you can either put them in separate classes, which you can then en/disable, or give each one a unique ID.

On the other hand, if you have a number of triggers all with the same pattern, it would be more efficient to have a single trigger with the pattern, which raises an event. Then, all of the different actions you conditionally want to occur can be placed in events. The name of each event would be whatever name you choose, and you #raise that event in your one actual trigger. Each event can then be given a unique ID, to allow you to enable and disable individually. The reason this would be more efficient is that, if you have multiple triggers, every line will have to be passed through each trigger pattern to test for a match. By using events, you only test the pattern in a single trigger.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Wed Oct 28, 2009 2:02 am   
 
Just to add to what Rahab said I would give your triggers unique IDs anyway. For starters, it makes it a lot easier to find them and also refer to them in code. For your situation, I would do what Rahab suggested and raise an event when that trigger fires and then create event handlers for looting and calculating experience when the event fires. You can also pass arguments to them.
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