# This is a "Device" in Verse. Think of it as a custom gadget you place in the world.
# It’s like a Race Manager, but instead of timing laps, it tracks loot points.
LootGoblinScore: device =
# --- VARIABLES (The "Boxes" for our data) ---
# TotalScore is like your current XP bar. It changes constantly.
# We start it at 0.
var TotalScore: int = 0
# PendingScore is like a "cart" before you check out.
# We add points here first, then dump them into TotalScore later.
# This prevents glitches if multiple things happen at once.
var PendingScore: int = 0
# This is a reference to the Score Manager device in the editor.
# We need to link this in the editor later!
ScoreManagerDevice: score_manager_device = score_manager_device{}
# This is the text box on the screen.
# We’ll use this to show the player their score.
ScoreText: text_block = text_block{}
# --- FUNCTIONS (The "Buttons" for logic) ---
# This function adds points to the "cart" (PendingScore).
# Imagine picking up a crate. You don't update the screen immediately.
# You just add it to your pocket.
AddPoints<public>(Points: int) : void =
PendingScore += Points
# We call UpdateUI to refresh the screen.
Verse Library
verse
01 Fragment
Manages pending and total score variables with a safe addition function and deferred interface refresh for gameplay scoring.
verse-library/4-add-a-scoring-system/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.