FlagsManager is an autoload singleton that provides a centralized store of named boolean flags. Use it to track persistent game state — tutorial completion, unlocked features, first-run flows, and any other binary condition that needs to be readable across different scenes and systems.
FlagsManager is registered as an autoload, so it is available from any script in the project. All flag values are bool — there are no integers, strings, or other types.Class overview
flags_manager.gd
FlagsManager loads a Flags resource (flags.tres) from uid://calw1rmsghoh8. Every entry in flags.tres is a named boolean value.
Initialization
_ready() enforces that every entry in flags.tres is strictly a boolean. If a flag is accidentally assigned a non-boolean value (for example during resource editing), check_item_types() logs an error at startup before any game logic runs.
API reference
get_flag(flag: String) -> bool
Returns the current value of the named flag.
The flag name as registered in
flags.tres. Case-sensitive.The current boolean value of the flag. Returns
false by default for flags that exist but have not been explicitly set to true.set_flag(flag: String, value: bool) -> void
Updates the value of the named flag and emits a debug log message.
The flag name as registered in
flags.tres. Case-sensitive.The new boolean value. Pass
true to activate the flag, false to deactivate it.Debug logging
Everyset_flag call prints a print_debug message in the format:
print_debug behavior.
Usage examples
- Check a flag
- Set a flag
- Toggle a flag
- Reset flags on new game
Practical example: tutorial gate
A common pattern in Beast Card Clash is usingFlagsManager and SceneManager together to route players correctly on game start.
The Flags resource
All flag names and their initial values are defined inflags.tres. Open this file in the Godot Inspector to view the full list of flags.
flags.tres is the single source of truth for valid flag names. You cannot call get_flag or set_flag with a name that does not exist in this resource — _flags.get_item() will raise an error.Adding a new flag
Open flags.tres in the Inspector
Locate
flags.tres in the FileSystem dock and open it. You will see the existing name → bool entries.Add a new entry
Add a new key-value pair. The key is your flag name (e.g.,
"first_battle_won"), and the value must be a boolean (false for a flag that starts inactive).Verify at startup
Run the project. If
check_item_types() in _ready() logs no errors, your flag is registered and valid.What flags are used for
Tutorial completion tracking
Tutorial completion tracking
The primary use case: gate first-time players into the tutorial and route returning players directly to battle. The
tutorial_completed flag is read on the main menu and set at the end of the tutorial scene.Feature toggles
Feature toggles
Enable or disable optional game features (e.g.,
show_hints, enable_experimental_mode) without code changes. Flip the flag in flags.tres and the behavior changes on next run.Progress milestones
Progress milestones
Track one-time achievements like winning a first battle (
first_battle_won) or unlocking a character skin. These flags persist for the session and can inform UI states across scenes.Debug and development flags
Debug and development flags
Add temporary flags (e.g.,
skip_intro, unlock_all_cards) during development to speed up testing. Because set_flag calls print_debug, every change is visible in the output panel.Related pages
Autoloads
Overview of all autoload singletons including
FlagsManager.SceneManager
Use
SceneManager.change_to_scene after reading a flag to route players.MusicManager
Combine with
FlagsManager to play different music based on game state.Architecture overview
How autoloads fit into the overall project structure.