API ReferenceGE Extensionscareermodules
Career Unlock Flags Module
M.dependencies = {"career_saveSystem"}
Dependencies
M.dependencies = {"career_saveSystem"}Boolean flag system for tracking unlockable career features. Flags are defined by other modules via the onGetUnlockFlagDefinitions hook and cached on first access. Supports lazy evaluation through unlockedFunction.
Public API
| Function | Signature | Description |
|---|---|---|
M.getFlag | (flagName) → bool | Returns flag value; lazily evaluates unlockedFunction on first access |
M.getFlagDefinition | (flagName) → table/nil | Returns the full flag definition |
M.setFlag | (flagName, value) | Manually sets a flag value in cache |
M.resetFlags | () | Clears the entire flag cache |
Lifecycle Hooks
| Hook | Purpose |
|---|---|
M.onCareerActivated | Resets cache and reloads flag definitions |
M.onSaveCurrentSaveSlot | (Stub - persistence code commented out) |
Dependencies
career_saveSystem(required) - save slot access
Flag Definition Format
Other modules register flags via onGetUnlockFlagDefinitions(flagDefinitions):
-- Example hook handler (not part of this extension):
local function onGetUnlockFlagDefinitions(flagDefinitions)
flagDefinitions["myFeatureUnlocked"] = {
unlockedFunction = function()
return career_branches.getBranchLevel("motorsport") >= 2
end,
icon = "trophy",
level = 2,
label = "Reach Motorsport Level 2",
}
endLocked Reason Format
getFlagLockedReason(flagName) returns:
{
type = "locked",
icon = "trophy",
level = 2,
label = "Reach Motorsport Level 2",
}Caching Behavior
- Flags are lazily cached:
unlockedFunction()runs only on firstgetFlag()call - Cache persists until
resetFlags()oronCareerActivated setFlag()overrides the cached value without callingunlockedFunction
Hooks Emitted
| Hook | Data |
|---|---|
onGetUnlockFlagDefinitions | (flagDefinitions) - modules insert their flag defs |
onUnlockFlagChanged | (flagName, value) - when setFlag is called |
Usage Example
-- Check if a feature is unlocked
if career_modules_unlockFlags.getFlag("cargoLogisticsMaterials") then
-- enable materials transport
endSee Also
- permissions - Runtime permission checks (different from persistent flags)
- playerAttributes - Attribute-based progression