# Import the core Verse library
using /Fortnite.com/Verse
# Import the game framework for interacting with players
using /Fortnite.com/GameFramework
# 1. Define the MAX_SCORE constant.
# This is like the "Win Condition" points. It’s set once in the editor and never changes.
const MAX_SCORE: int = 100
# 2. Define the current score variable.
# We use 'constrained' to set limits.
# min: 0 (You can't have negative points)
# max: MAX_SCORE (You can't have more than 100 points)
var Current_Score: int = constrained(0, MAX_SCORE)
# This function simulates a player getting an elimination.
# In a real game, this would be triggered by an Elimination Event.
function Add_Points(points: int) -> void:
# Calculate the new potential score
new_score: int = Current_Score + points
# Here’s the magic: We try to assign the new score to our constrained variable.
# If new_score is 150, Verse will automatically clamp it to 100 because of the constraint.
# If new_score is -5, it will clamp to 0.
Current_Score = new_score
# Let's print what happened so we can see the constraint in action
Print("Score updated to: " + Current_Score)
Verse Library
verse
01 Fragment
Uses Verse constrained types to automatically clamp score values between limits.
verse-library/constraints/01-fragment.verse
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.