# This is our main device class. # It acts like the brain of our scoreboard. class ScoreTrackerDevice is WorldDevice(): # This is our Map! # It maps a Player (the Key) to an Integer (the Value). # We call it PlayerScores. PlayerScores : [Player]int = map{} # This function runs when the game starts. OnBegin(): void = # We start with an empty map. # It is ready to store scores! Print("Scoreboard is ready!") # This function runs when a hit happens. # We will connect a Trigger to this later. HandleHit(Attacker: Player, Target: Entity): void = # Check if the attacker is actually a player. # If they are not a player, we stop here. if (Attacker == None): return # Look up the current score for this player. # If the player is not in the map yet, # the default value for int is 0. CurrentScore : int = PlayerScores[Attacker] # Add 1 to their score. NewScore : int = CurrentScore + 1 # Update the map with the new score. # We use the player as the Key. PlayerScores[Attacker] = NewScore # Tell everyone what happened! Print("{Attacker.Name} now has {NewScore} points!")