Verse Library verse

01 Fragment

Tracks flag ownership, updates team accent colors on pickup, and resets state when dropped.

verse-library/capture-the-flag/01-fragment.verse

# 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

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in