Pipeline for creating custom trigger via script

Hey guys,

What’s the pipeline of building custom trigger script in LS?

So, basically I want to send custom trigger from one script to another each time the condition is met. I know I can use “global.variable” and use it in another script to see if it is true or false, but that’s not a very good from optimization point - this way another schipr shall check “true/false” condition each frame instead of doing smth only once the condition is met.

Check out the behavior script. It has some comments about how to send and receive custom events

1 Like

I don’t know how that happened, but I have checked behavior script several times to get the idea of how they manage custom triggers, and it was hard to understand since these 2k+ lines if code doesn’t have any comments explaining the blocks.

After you comment I decided to check again and this is the first time I see this comment :smiley:

// ---- GLOBAL API USAGE ----
// Manually send a global custom trigger
//  global.behaviorSystem.sendCustomTrigger(triggerName)
//
// Add a callback function to call when the global custom trigger named "triggerName" is sent
//  global.behaviorSystem.addCustomTriggerResponse(triggerName, callback)
//
// Remove a callback function for the global custom trigger named "triggerName"
//  global.behaviorSystem.removeCustomTriggerResponse(triggerName, callback)
// -----------------

Banner blindness. I got so used that first lines of code consist only general useless description (like version, event, etc), so automatically omitted it.