using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /Verse.org/Native } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our device. It controls the glowing box. GlowingBoxDevice := class(creative_device): # This is a variable. It holds a trigger_device. # We connect this in the UEFN Details panel. # A variable is a container for data. @editable HitTrigger : trigger_device = trigger_device{} # This is another trigger for the next box in the chain. # Wire this to the next GlowingBoxDevice to create the domino effect. @editable NextTrigger : trigger_device = trigger_device{} # This controls a customizable light device placed near the box. # Place a customizable_light_device in UEFN and connect it here. @editable GlowLight : customizable_light_device = customizable_light_device{} # This function runs when the game starts. # "override" means we are changing how the device works. # "suspends" means it can wait for things. OnBegin() : void = { # Subscribe to the trigger so we know when the box is hit. # "Subscribe" means: run this code when the event fires. HitTrigger.TriggeredEvent.Subscribe(OnBoxHit) } # This event runs when something hits the trigger around the box. OnBoxHit(Agent : ?agent) : void = { # Spawn the FlashColor task so it can use Sleep without # blocking other code. "spawn" starts a new async task. spawn { FlashColor() } } # A helper function to flash the color. # "" lets us use Sleep to wait inside this function. FlashColor() : void = { # Turn the glow light on bright to look like a flash. # customizable_light_device has SetEnabled to turn it on/off. GlowLight.TurnOn() # Wait for a short time. # "Sleep" pauses this task without freezing the whole game. Sleep(0.5) # Turn the light back off so it looks like a brief glow. GlowLight.TurnOff() # Fire the next trigger in the chain to keep the domino going. # This activates whatever device is listening to NextTrigger. # note: trigger_device has no direct Activate(); connect # NextTrigger's output to the next box's HitTrigger in UEFN # device wiring, or replace with a direct device reference call. }