config
Plan-level file management. Menu values still go through gui.set / gui.get — config.* only handles plan switching / listing / saving as a new plan.
| Method | Description |
|---|---|
config.save() | Save the current plan. Writes asynchronously, the file may not be on disk when it returns |
config.save_as(plan_name) | Save under a new plan name, the current plan does not change |
config.switch(plan_name) | Switch to the given plan |
config.list() → table<string> | List all available plan names |
config.current() → string | Current plan name |
No
config.load— it would duplicateconfig.switch.
Behavior notes
None of these return a value. A failure is only logged, so do not test the return value.
- Any extension in the name is stripped,
"cqc.preset"means"cqc". - If the target plan does not exist,
config.switchis not an error: it creates a plan of that name from defaults and switches to it. A typo silently produces a new plan and replaces the current settings with defaults — checkconfig.list()first. - After switching, scripts are synced against the new plan's list: scripts not on it are unloaded (including the script that called switch), listed scripts not yet loaded are loaded. Then
config_changedfires. Code after switch must not assume its own controls still exist. config.save_asrejects an empty name and the namedefault, again without reporting it.
Example
lua
log.info("Current plan: " .. config.current())
log.info("Available plans: " .. table.concat(config.list(), ", "))
-- Switch to cqc, plan names carry no extension. switch returns nothing, read current() to confirm
config.switch("cqc")
gui.notify:success("Switched to " .. config.current(), 2.0)