# We are defining a "Script" which is a container for our game logic. # Think of this like a blueprint for a specific device. script BarnTrapScript is scriptable # This is the "Scene Graph" connection. # We need to tell the script which specific devices to control. # 'trigger' is the name of the variable we'll use in the Outliner. trigger: Trigger Volume = Trigger Volume'None' # 'launcher' is the Prop Mover device. launcher: Prop Mover = Prop Mover'None' # This is a Variable. # It stores a boolean (true/false) value. # Think of it like a "Cooldown" timer that is either ON or OFF. is_cooldown: bool = false # This is an Event. # Events are like "listening devices." # The game calls this function when the condition is met. @event OnPlayerEnter(trigger: Trigger Volume, player: Player) is server # Check if the cooldown is active. # If is_cooldown is true, we ignore the player. if is_cooldown == true return # Stop the function here. # If we are here, the trap is ready to fire. # 1. Set the cooldown to true (so it doesn't fire again immediately). is_cooldown = true # 2. Activate the Prop Mover. # We are calling a function on the 'launcher' device. launcher.Activate() # 3. Reset the trap after 5 seconds. # We use a timer to wait, then set is_cooldown back to false. @event on_timer() is server is_cooldown = false # Note: In a real complex script, you'd handle the timer # lifecycle carefully, but for this simple example, # we rely on the event structure. # *Simplified for beginner clarity*: # We'll use a simpler approach below for the reset.