# Import the basic framework for Verse using /Fortnite.com/Devices # This is our "Device Class". It’s like a blueprint for our Spooky Trap. # We are telling Verse: "I want to control a Post Process device." spooky_trap := class(device): # This is a VARIABLE. Think of it as a storage box. # We store the Post Process device here so we can talk to it. # It's like pointing at the sunglasses and saying "You, I'm talking to you." filter_device: PostProcessDevice = PostProcessDevice{} # This is an EVENT. It’s like a button press. # When a player enters the trigger zone, this function runs. OnBegin(): void= # Wait for the device to be ready (just like waiting for the bus) await GetWorld().GetTimer().Wait(0.0) # Connect the "On Player Enters" event to our function # This is like wiring a switch to a light bulb. # When someone steps on the rug, 'HandlePlayerEnter' gets called. self.GetTrigger().OnPlayerEnter += HandlePlayerEnter self.GetTrigger().OnPlayerLeave += HandlePlayerLeave # This function runs when a player steps IN. HandlePlayerEnter := func(player: Player): void= # Activate the filter! # We are calling the 'Activate' function on our stored device. # It’s like putting on the sunglasses. filter_device.Activate() # This function runs when a player steps OUT. HandlePlayerLeave := func(player: Player): void= # Deactivate the filter! # It’s like taking the sunglasses off. filter_device.Deactivate() # Helper function to get the trigger volume we placed in the editor # We assume the device has a trigger attached to it in the editor. GetTrigger := func(): TriggerVolume= # In a real scenario, you'd link a Trigger Volume device to this script. # For simplicity in this tutorial, we assume the device has a default trigger. # Note: In actual UEFN, you often use 'GetTrigger()' from the base device # if a trigger is linked, or you reference a separate Trigger Volume device. # Here we simplify by assuming the Post Process device has its own trigger # or we are referencing a linked device. # *Correction for accuracy*: Post Process devices don't have triggers. # We need a separate Trigger Volume device. Let's adjust the class to # include a Trigger Volume reference. pass # See updated code below for the correct structure