Game Profiles
On this page
The core.game_profiles module lets a script manage the account's game profiles, the same ones listed under Game Profiles in the web menu: list them, create, edit and delete them, launch them, and close the games they started.
Not to be confused with core.profiles, which handles saved settings profiles.
Violet keeps the profile list current in the background, so list(), get() and get_current() answer at once and are safe to call every tick. A profile created, edited or deleted anywhere (the web menu, another script, another game) shows up within about a second.
The other functions send a request and return a request id straight away. The outcome arrives a moment later: read it with result(), or handle it in the on_game_profile_result callback. When a request can't be sent, the function returns nil and a reason, and nothing is sent: "not_connected" when the game is not connected to Violet, or "invalid" when the request is too large to send (for example, an extremely long name).
Scripts can create profiles and start games on your account, but they can never read a profile's email or password back. Only run scripts you trust with these functions.
Reading profiles
core.game_profiles.list() -> table | nil
Available on GMS and CW
Returns the account's game profiles in the web menu's order, or nil until the first list arrives just after the game connects to Violet. Each entry is a table:
| Field | Type | Description |
|---|---|---|
id | number | Profile id. Pass it to the other functions. |
name | string | The profile's display name, or a masked email (ab***@example.com) when it has none |
game | string | "gms" or "classic" |
auto_relaunch | boolean | true when the launcher re-opens the game whenever it closes |
settings_profile_id | number | nil | The settings profile the game starts with, an id from core.profiles.list(); nil when none is pinned |
running | boolean | true while a game started from this profile is running on the account |
is_current | boolean | true for the profile this game was started from |
At most 512 profiles are listed, and fewer when names are long. When the list is cut, every entry carries truncated = true.
for _, p in ipairs(core.game_profiles.list() or {}) do
core.log(string.format("#%d %s (%s)%s", p.id, p.name, p.game, p.running and " - running" or ""))
endcore.game_profiles.get(id: number) -> table | nil
Available on GMS and CW
Returns the profile with that id, with the same fields as a list() entry, or nil if the account has no such profile or the list hasn't arrived yet.
core.game_profiles.get_current() -> table | nil
Available on GMS and CW
Returns the profile this game was started from, or nil if the game was not started from a profile or the list hasn't arrived yet.
Changing profiles
core.game_profiles.create(options: table) -> number | nil, string?
Available on GMS and CW
Creates a game profile for the game this script runs in. Returns the request id, or nil, "not_connected". On success the result's profile_id is the new profile's id, and the profile is already in list() when the result arrives.
| Field | Type | Description |
|---|---|---|
email | string | Required. The game account's email. |
password | string | Required. The game account's password. |
name | string? | Display name |
auto_relaunch | boolean? | Re-open the game whenever it closes. Default false. |
settings_profile_id | number? | Settings profile the game starts with; 0 or leaving it out pins none |
The new profile launches with the game path set for that game in each computer's settings in the web menu.
local request = core.game_profiles.create({
email = "[email protected]",
password = "hunter2",
name = "Alt 3",
})core.game_profiles.update(id: number, changes: table) -> number | nil, string?
Available on GMS and CW
Edits a profile. Only the fields you pass change: name (pass "" to clear it), email, password, auto_relaunch and settings_profile_id (pass 0 to unpin the settings profile). Returns the request id, or nil, "not_connected".
core.game_profiles.delete(id: number) -> number | nil, string?
Available on GMS and CW
Deletes a profile. Refused with error = "running" while a game started from it is running. Returns the request id, or nil, "not_connected".
Launching and closing
core.game_profiles.launch(id: number, options?: table) -> number | nil, string?
Available on GMS and CW
Launches the profile on the computer this game runs on. options.settings_profile_id starts it with that settings profile instead of the profile's own; 0 or leaving it out keeps the profile's own. Returns the request id, or nil, "not_connected".
A successful result means the launch was queued, not that the game is open. The profile's running turns true once the new game connects to Violet.
local request = core.game_profiles.launch(42)core.game_profiles.terminate(id: number) -> number | nil, string?
Available on GMS and CW
Closes every game on the account that was started from the profile. Returns the request id, or nil, "not_connected". A result with error = "not_running" means none was running; error = "failed" means at least one of them could not be confirmed closed.
Terminating the profile this game was started from closes this game, and your script with it.
Results
core.game_profiles.result(request_id: number) -> table | nil
Available on GMS and CW
Returns the outcome of a request, or nil while it is still pending (or the id is unknown). Reading an outcome does not remove it: the 64 most recent outcomes stay readable. A request that gets no answer within 30 seconds fails with error = "timeout".
A timeout means no answer arrived, not that the request failed: it may still have gone through. Check list() before retrying a create(), or you may create the profile twice.
| Field | Type | Description |
|---|---|---|
ok | boolean | true if the request succeeded |
error | string | nil | Why it failed (see below) |
message | string | nil | A short explanation you can show the user |
profile_id | number | nil | The profile the request was about; for create, the new profile |
error | Meaning |
|---|---|
"invalid" | A field is missing, the wrong type or too long |
"not_found" | The account has no profile (or settings profile) with that id |
"limit" | The account already has 500 game profiles, the most a script can create up to |
"rate_limited" | Too many requests in a short time (more than 5 at once, then 1 per second), or more than 30 profiles created on the account in the last hour |
"running" | Refused because a game started from this profile is running |
"not_running" | terminate() found no game started from this profile |
"no_computer" | This game was not started by the Violet launcher, so there is no computer to launch on |
"computer_offline" | The launcher on this computer is not connected |
"no_game_path" | This computer has no game path set for that game |
"busy" | A launch of this profile is already in progress, or the launcher didn't answer in time (the game may still open) |
"timeout" | No answer within 30 seconds, or too many requests were waiting at once |
"failed" | Anything else; see message |
local pending = core.game_profiles.launch(42)
function on_tick()
if not pending then return end
local r = core.game_profiles.result(pending)
if not r then return end
pending = nil
if r.ok then
core.log("Launch queued")
else
core.log_error("Launch failed: " .. r.error .. (r.message and (" - " .. r.message) or ""))
end
endExample: keep two alts running
Launches each listed profile that isn't running, one request at a time, and gives each launch three minutes to connect before trying it again.
plugin = {
name = "Alt Keeper",
version = "1.0.0",
author = "you",
description = "Relaunches the listed game profiles when they close",
load = true,
}
local ALTS = { 42, 43 }
local RETRY_MS = 180000
local launched_at = {}
local pending
function on_game_profile_result(request_id, result)
if request_id ~= pending then return end
pending = nil
if not result.ok then
core.log_warning("Launch of #" .. tostring(result.profile_id) .. " failed: " .. result.error)
end
end
function on_tick()
if pending then return end
local now = core.get_update_time()
for _, id in ipairs(ALTS) do
local p = core.game_profiles.get(id)
if p and not p.running and now - (launched_at[id] or -RETRY_MS) >= RETRY_MS then
pending = core.game_profiles.launch(id)
if pending then
launched_at[id] = now
end
return
end
end
end