Getters
Overview
Once your configs are set up in Setup, you need a way to fetch values in your game code. Figgy provides getters for all three sets of config structs: Current, Initial, and Default.
- .GetCurrent() returns the current config struct that you edit through the Interface and access throughout your game code.
- .GetInitial() returns the initial config struct, captured after defaults are initialized in Setup and saved changes (if any) are loaded at game startup.
- .GetDefault() returns the default config struct that holds the original baseline values defined in Setup.
Getters
.GetCurrent()
Figgy.GetCurrent()➜ Struct
Returns the current config struct that you edit through the Interface and access your game code.
TIP
I highly recommend storing the current config struct in a convenient global + macro pair for cleaner access instead of having to call Figgy.GetCurrent() for grabbing each config value.
You'll need to do it at the start of your game where you perform initialization. Make sure it's done after scripts are initialized (in some master object's Create event, or the first room's Creation Code) and before you need to access your first configs.
// Set up global + macro:
#macro CFG global.__config
CFG = Figgy.GetCurrent();
// In objPlayer's Create event, store the config struct for future use:
cfg = CFG.Player;
// In objPlayer's MoveX() method, grab the MoveSpeed variable from the config struct:
MoveX = function() {
xSpd = InputX(INPUT_CLUSTER.MOVEMENT) * cfg.MoveSpeed;
};function FiggySetup() {
Figgy.Window("Player");
// Sections, Groups and Value Widgets here...
Figgy.Window("Enemies");
Figgy.Section("Skeleton");
// Value Widgets here...
}{
Player: {
// Section/Group structs and Value Widget values here...
},
Enemy: {
Skeleton: {
// Group structs and Value Widget values here...
},
},
}// In objPlayer's Create event, store the config struct for future use:
cfg = Figgy.GetCurrent().Player; // Without global + macro.
cfg = CFG.Player; // With global + macro.
// In objEnemySkeleton's Create event, store the config struct for future use:
cfg = Figgy.GetCurrent().Enemies.Skeleton; // Without global + macro.
cfg = CFG.Player; // With global + macro..GetInitial()
Figgy.GetInitial()➜ Struct
Returns the initial config struct, captured after defaults are initialized in Setup and saved changes (if any) are loaded at game startup.
The method is primarily intended for resetting the current config back to its initial state using the Interface or the .ResetToInitial() method, but feel free to use it for any other purpose.
var _initialConfig = Figgy.GetInitial(); .GetDefault()
Figgy.GetDefault()➜ Struct
Returns the default config struct that holds the original baseline values defined in Setup.
The method is primarily intended for resetting the current config back to its default state using the Interface or the .ResetToDefault() method, but feel free to use it for any other purpose.
var _defaultConfig = Figgy.GetDefault(); 