Verse Library verse

01 Device

Manages shooting targets by tracking hits, preventing double scoring, and awarding points to players.

verse-library/add-targets/01-device.verse

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# This is our main brain. It holds the score and knows about the targets.
shooting_range_manager_device := class(creative_device):
    
    # The device that actually tracks the player's score.
    # Think of this as the scoreboard in the lobby.
    @editable
    ScoreManager:score_manager_device = score_manager_device{}
    
    # This is a "Wrapper" class. It bundles a target device with its specific rules.
    # It’s like a "Loot Table" entry: here is the item, here is the value.
    TargetInfo := struct:
        # The actual target device in the world
        Target:shooting_range_target_device = shooting_range_target_device{}
        # How many points this target is worth
        Points:int = 0
        # Has this target already been hit in this round? (Prevents double-dipping)
        IsHit:bool = false
        
        # This function runs when the target is hit.
        OnTargetHit := func():void =
            # If we already hit this one, do nothing. 
            # It’s like trying to pick up a loot item that’s already gone.
            if (IsHit?):
                return
            
            # Mark it as hit so we don’t score it again.
            IsHit = true

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