# This is a Verse Script. It runs on the device it's attached to. # 1. Define the Variables (The "Inventory Slots") # 'Flag_Spawner' is a link to the Capture Item Spawner in the Outliner. # We use 'var' to say this value can change during the game. var Flag_Spawner: Capture_Item_Spawner = Get_Device("Flag_Spawner") # 'Current_Holder' tracks who has the flag. # 'None' means no one is holding it. # 'Team_1' or 'Team_2' will be set when someone grabs it. var Current_Holder: Player = None # 2. The Event (The "Trigger") # This function runs automatically when a player interacts with the flag. # 'On_Flag_Collected' is a built-in event for Capture Item Spawners. On_Flag_Collected: func(player: Player) -> void: # Update the variable! The player who picked it up is now the holder. Current_Holder = player # Let's do something visible: Change the flag's color to show it's stolen. # We assume the Flag has a material parameter called 'TeamColor'. # This is a simplified example of changing visual state based on logic. Flag_Spawner.Set_Accent_Color(player.Get_Team()) # 3. The Drop Event # This runs when the player drops the flag or gets eliminated. On_Flag_Dropped: func(player: Player) -> void: # Reset the variable. No one is holding it now. Current_Holder = None # Reset the visual state. Flag_Spawner.Set_Accent_Color(Team_None) # 4. The Game Loop (The "Timer") # This function runs every single frame (about 60 times a second). # We use this to check if the game is running or handle continuous logic. Tick: func() -> void: # If someone is holding the flag, maybe we want to slow them down? # For now, let's just print a debug message to the screen (in the console). if Current_Holder != None: # This is a simple check. If the holder is still valid... # In a real game, you'd add more complex checks here. pass else: # If no one holds it, the flag is safe. pass