Profiles
On this page
The core.profiles module lets a script read the user's saved settings profiles and switch the session between them — the same profiles shown in the web menu's profile bar.
Profile metadata (id and name) is mirrored on the client and kept up to date as profiles are created, renamed, or deleted, so reading the list or the active profile is instant and safe to call every tick — there is no round-trip to the server. Switching a profile applies that profile's full saved settings, which takes a moment to propagate.
Functions
core.profiles.list() -> table
Returns an array of the user's settings profiles, ordered as in the web menu. Each entry is a table:
| Field | Type | Description |
|---|---|---|
id | number | Stable profile id. Pass this to switch() to avoid name clashes. |
name | string | Profile name as shown in the web menu. |
active | boolean | true for the profile currently applied to this session. |
Reads from the local metadata cache, so it returns immediately.
for _, p in ipairs(core.profiles.list()) do
core.log((p.active and "* " or " ") .. p.name .. " (#" .. p.id .. ")")
endcore.profiles.get_active() -> table | nil
Returns the profile currently applied to this session as { id = number, name = string }, or nil if no profile is active.
local active = core.profiles.get_active()
core.log("Active profile: " .. (active and active.name or "(none)"))core.profiles.switch(profile: string | number) -> boolean
Switches the session to a saved profile, identified by name or by id. Returns true if the profile exists and the switch has started (or it is already the active profile), or false if the name/id isn't found or a switch is already in progress.
Pass a name for readability (core.profiles.switch("Bossing")), or an id from list() when profile names might collide.
switch() returning true means the swap was accepted, not that the new settings are live yet — the profile's full settings load and apply a moment later. While a switch is in flight, further switch() calls return false until it finishes (reads stay instant). To act once the swap lands, poll get_active() until it reports your target profile.
if not core.profiles.switch("Bossing") then
core.log_error("Switch rejected — unknown profile, or a switch is already running")
endcore.profiles.save([options: table]) -> boolean
Saves the session's current settings to the active profile — the same as pressing Save in the web menu's profile bar. Returns true if the save request was sent.
By default the whole settings set is saved. Pass an options table to save only part of it:
| Field | Type | Description |
|---|---|---|
sections | table (strings) | Top-level categories to save in full, e.g. { "lua" }. |
keys | table (strings) | Individual setting paths to save, e.g. { "hacks.godmode" }. |
When sections/keys are given, only those parts are written onto the saved profile — every other setting already in the profile is left untouched.
-- Save everything to the active profile
core.profiles.save()
-- Save only the Lua section (leaves the rest of the profile as-is)
core.profiles.save({ sections = { "lua" } })
-- Save just two specific settings
core.profiles.save({ keys = { "hacks.godmode", "autos.auto_pot.hp.value" } })core.profiles.save_as(name: string [, options: table]) -> boolean
Creates a new profile from the session's current settings. If a profile with that name already exists, a numbered suffix is added automatically (e.g. "Build (1)"). Takes the same options filter as save(). Returns true if the save request was sent.
core.profiles.save_as("Bossing Build")
-- New profile that only differs from defaults in the Lua section
core.profiles.save_as("Lua Only", { sections = { "lua" } })Like switch(), a true return means the request was accepted, not that the profile list has updated yet. The new or updated profile appears in list() a moment later, once the server confirms the save.
Example: report profile changes
Logs the profile list once on load, then reports whenever the active profile changes — whether the swap came from this script, another script, or the web menu.
plugin = {
name = "Profile Watcher",
version = "1.0.0",
author = "you",
description = "Logs the profile list and reports active-profile changes",
load = true,
}
local last_active
function on_map_load()
for _, p in ipairs(core.profiles.list()) do
core.log((p.active and "* " or " ") .. p.name)
end
end
function on_tick()
local active = core.profiles.get_active()
local name = active and active.name or "(none)"
if name ~= last_active then
last_active = name
core.log("Active profile is now: " .. name)
end
end