construct.net/en/make-games/manuals/construct-3/project-primitives/events/functions
It seems like experienced users use functions more than others, and that it's a preferable to use them as often as you can.
However, it's not super clear to me how functions function.
How are triggers checked?
construct.net/en/make-games/manuals/construct-3/project-primitives/events/how-events-work
Rather than running once per tick, this event simply runs (or "fires") upon something actually happening. In this case, the event runs when the user hits the Spacebar key on the keyboard. It is never checked any other time.
How can that work?
How can it just miraculously know to run the trigger when that the button is pressed?
Why doesn't the computer need to check every tick to see if that button is being pressed?
Why aren't all triggers checked to see if they're true every tick?
For me, functions feel magical and mysterious compared to regular events, where we know they run from top to bottom, being checked in a logical way.
Does this mean triggers are always better for performance because they're not always being checked like regular events are?
If you have hundreds of triggers from objects that are currently all destroyed, does that mean that these events/triggers effectively don't exist, they're never checked?
For example, the trigger "On Collision", wouldn't you need to check that just as often as "Is overlapping"?
And with ones like "On animation finished", wouldn't the engine need to keep checking to see what the animation is up to?
Thank you for clarifying!