# This is a comment. It helps humans read the code.
# Verse ignores these lines.
# Step 1: Declare the variable
# We create a variable named 'CurrentScore'.
# It is an 'int' (integer/whole number).
# We start it at 0.
var CurrentScore : int = 0
# Step 2: Define the function that runs when a player enters
# 'OnBegin' is a special event. It runs when the game starts.
OnBegin[Source : Entity] = () =>
# We don't do much here yet, just setup.
() =>
# Step 3: Define the function for when a player enters the trigger
# 'OnBeginPlay' is called when the player starts playing.
# We will link this to a Trigger Volume in the editor.
OnPlayerBeginPlay[Source : Player] = () =>
# This part runs when the player enters the trigger.
# We use 'set' to change the variable.
# We add 1 to the current score.
set CurrentScore += 1
# For this simple example, we print to the debug console.
# In a real game, you would show this on the screen.
print("Score is now: ", CurrentScore)
Verse Library
verse
01 Fragment
Updates a score variable when a player enters a trigger volume, demonstrating basic trigger-event scoring.
verse-library/declaring-a-variable/01-fragment.verse