Next: Variables: The Connective Tissue, Previous: Connecting the Dots: Events in Action, Up: The Rules File: Where the Magic Happens [Contents]
Now that you’ve got a feel for how to define a target, I want to show you the second main construct of the STARTER language:
TRIGGER WHEN condition SET target = value;
While the first method (the target { ... } block) defines a set of rules for a single objective, the TRIGGER allows you to define multiple assignments linked to a specific event.
Let’s go back to our oil price example:
TRIGGER WHEN oil:price < 100 SET beep:status = TRUE; TRIGGER WHEN oil:price > 100 SET beep:status = FALSE;
We’ve achieved the exact same result as before, but with a different syntax. This leads to a natural question: When should you use TRIGGER instead of a target block?