Skip to content

Conditions

Daedalus1400 edited this page May 18, 2017 · 2 revisions

Order is Important

Conditions are checked in the order they are listed in the config file. Upon a condition returning false, the loop exits early. This leads to ordering conditions in a specific way to both optimize performance and ensure expected behavior.

For example, if a list of conditions includes a "chance" condition with a low probability of returning true, then it should be placed earlier in the list, preferably first. Since the loop will exit early on finding the first false condition, this means that the subsequent conditions will not be checked, saving processor time.

Another example: if a list of conditions includes a "once" condition, it should always be the last condition. If it is not the last condition and it is evaluated, it will return true, but the condition after it may not, resulting in the event not triggering that tick. However, the "once" has already "spent" its one true value, and will always return false afterwards, so the event will never trigger at all.

Following from the optimization mentioned in the "chance" example, conditions that have lower probability should be earlier in the list to reduce the total processor time needed to evaluate conditions.

Clone this wiki locally