trigger advice: 'OR' type or individual triggers?

Post Reply
Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

trigger advice: 'OR' type or individual triggers?

Post by Caled »

An example, albeit it a simple one.

I like to trigger certain npc attacks to clot certain amounts. Since this is the same command (its almost always either 'clot 3') I could use a single trigger with an 'or' conditional for each mob attack. Or I could just create a new trigger for each one.

I see no benefit to either way, other than it being marginally quicker to add a new mob attack trigger to clot from, if all I am doing is adding the pattern as an extra conditional.

Its barely even worth asking the question about other than as a curiosity. If this trigger had 30 'or' conditions to it, would trigger parsing as a whole operate as quickly as in the scenario where I have 30 separate triggers instead?

There are all sorts of applications where I could use many multiple OR conditionals, yet don't have to to get the job done. So I'm asking about performance now, before I create any of them.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: trigger advice: 'OR' type or individual triggers?

Post by Heiko »

The OR version would be a bit faster. However, I'd rather base system design decisions on what approach suits your general design better. Using long expression lists instead of lots of individual triggers cuts down significantly on the number of trigger items which is a good thing in general for a number of reasons. However, if you want to enable or disable certain subtriggers/expression individually at some point you should consider splitting off those expressions and make them individual triggers instead. The question is: Does this trigger need to be regarded as an individual entity or is it rather a part of some other unit.
You should be using the higher level trigger entities in Mudlet as much as possible as it really speeds up your overall system while making things simpler for you at the same time. If you are using chains, filters( beta-10 or current git version) or multiline triggers Mudlet takes care of automatically cutting down the number of active triggers down to a minimum and you don't have to mess with enabling/disabling trigger groups yourself as much, but you can concentrate on enabling/disabling the relevant major groups instead. On big system this is a *HUGE* advantage. System design is a complex problem that needs special attention, especially if you plan on making a big system. I'll add a system design article to the manual in a couple of weeks. Time spent on design issues always pays off mightily in the long run.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: trigger advice: 'OR' type or individual triggers?

Post by Vadi »

You definitely would find it easier to manage them if they're grouped together into 'or'.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: trigger advice: 'OR' type or individual triggers?

Post by Caled »

I did that with a bunch of channel cap trigger lines (though I could have used regex to match them all with a single pattern.)

I noticed something odd though. When I add a new trigger pattern to the list, it doesn't actually start firing until I enable and disable a different trigger. I plan to look into it properly a bit later and submit a proper bug.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: trigger advice: 'OR' type or individual triggers?

Post by Heiko »

That's because of the autosaving code. Mudlet somehow has to know when you've finished your changes in order to forward the new or updated item to the trigger engine.
If you press on the save button the new item will instantly be processed. Changing focus to a new item e.g. adding a new trigger or clicking on some other trigger will cause the save button to be pressed for the previous item to simplify usage.
To sum up, to save an item you either have to click on the save icon, add another trigger or click on another trigger.

Post Reply