Verse Library verse

01 Fragment

Adds points to a specified team and logs the update.

verse-library/using-the-score-manager-device-to-track-points/01-fragment.verse

# This is a simple Verse script for scoring
# It uses the Score Manager device

# We need to find our Score Manager device
# This is like finding a specific toy in a box
my_score_manager := ScoreManager{}

# This function runs when the game starts
# It sets up the rules for our game
OnBegin<override>()<suspends>:void=>
    # We do not need to do anything yet
    # But we are ready to score!
    pass

# This function adds points to a team
# It is like a helper robot
AddPoints(team_index: int, points: int): void =>
    # This line gives points to the team
    # It uses the Score Manager we found earlier
    my_score_manager.AddScore(team_index, points)
    
    # This line prints a message to the screen
    # It helps us see what is happening
    print("Team ", team_index, " got ", points, " points!")

Comments

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