// This is our "Blueprint" for the game logic. // It inherits from GameScript, which means it lives in the world and watches everything. script class CaptureFlagGameScript is GameScript: #region Variables (The Scoreboards) // A variable is like a loot box that holds a value. // We use 'int' (integer) for whole numbers. // These start at 0. Blue_Score: int = 0 Red_Score: int = 0 // A constant is a rule that never changes. // The win condition is always 3 points. const WIN_SCORE: int = 3 #endregion #region Events (The Triggers) // An event is a signal that says "Something happened!" // This function runs automatically when the game starts. event OnBegin(): // When the match starts, let's announce it. Print("Match Started! First to 3 captures wins.") #endregion #region Logic (The Brain) // This is a custom function we will call manually when a capture happens. // 'team' is a label (like "Blue" or "Red"). function OnFlagCaptured(team: string): // We use an 'if' statement. It's like a decision tree. // If the team is Blue, add 1 to Blue's score. if (team == "Blue"): Blue_Score += 1 Print("Blue captured the flag! Score: ", Blue_Score) // Check if Blue won if (Blue_Score >= WIN_SCORE): Print("BLUE WINS THE MATCH!") # Note: In a full game, you'd trigger the Win Screen device here. # If the team is Red, add 1 to Red's score. else if (team == "Red"): Red_Score += 1 Print("Red captured the flag! Score: ", Red_Score) # Check if Red won if (Red_Score >= WIN_SCORE): Print("RED WINS THE MATCH!") #endregion