clientSettings
The client's settings: the person's own on this device for the account signed in, the same in every world, on every platform and in a headset. Each one is declared once by the engine, in a group: a key, the field its value must satisfy, the scope it is kept in, and the effect a change has. clientSettings.list() states every group with each entry's value and where that value comes from; set, reset and run change them. They show as the System tab of the app menu (appMenu), each group one of its sections. A world reads them (clientSettings.get("xr.perspective")) and opens them (clientSettings.open()), and never changes them: a write with world or agent code behind it is refused, whether that code is on the stack or started or resumed the coroutine or task the write runs on (or one further back). They are a different thing from the world's own settings file (settings).
require("@builtin::modules.api.engine.client_settings") -- clientSettings (also available as global 'clientSettings')
The clientSettings namespace: 44 functions.
globals/clientSettings/buildSection
clientSettings.buildSection(model: { [string]: any }) -> { [string]: any }
The System tab's widget tree, drawn from list(), in the room
model.width x model.height the app menu leaves it: the visible groups
as sections (down the side on a desktop and a headset's panel, across the
top on a phone) and the entries of the one chosen, each with its control,
and a way to put the group back to its defaults.
Parameters
model{ [string]: any }—{ width, height, presentation?, group?, groups? }:groupsis thelist()to draw, the current one when left out.
Returns { [string]: any } — The widget tree.
globals/clientSettings/close
clientSettings.close()
Close the app menu.
globals/clientSettings/get
clientSettings.get(key: string) -> any
The value of the setting under key: the one the person chose, or
the setting's default while they chose none.
Parameters
keystring— The setting's dotted key, e.g."xr.perspective".
Returns any — The value; nil for a key no setting is declared under.
local perspective = clientSettings.get("xr.perspective")
globals/clientSettings/isOpen
clientSettings.isOpen() -> boolean
Whether the app menu shows the System tab.
Returns boolean
globals/clientSettings/list
clientSettings.list() -> { GroupRow }
Every group declared, in its order, each with its entries: a
setting's value, default, where the value comes from ("player" once the
person chose one, "default" before), its scope, its choices or range,
and whether it can be used now; an action's button. A group's visible
says whether its tab shows on this client now. The settings menu draws
exactly this.
Returns { GroupRow }.
for _, g in clientSettings.list() do print(g.title, #g.entries) end
globals/clientSettings/onChanged
clientSettings.onChanged(fn: (key: string?, value: any) -> ()) -> () -> ()
Call fn(key, value) whenever a setting changes, and fn(nil) when
the account they belong to changes.
Parameters
fn(key: string?, value: any) -> ()— The listener.
Returns () -> () — A function that stops the listener.
globals/clientSettings/open
clientSettings.open(group: string?)
Open the app menu on its System tab: over the window on desktop, as a world panel in front of the person in a headset. Every way in opens the same menu, a world's own pause tab included.
Parameters
groupstring(optional) — The section to open on ("vr"), or the one shown last.
globals/clientSettings/reachable
clientSettings.reachable() -> boolean
Whether some group of the settings shows on this client now. The System tab of the app menu and the editor's ways into it (its menu, the dock in a headset) show while one does.
Returns boolean — Whether some group is visible.
globals/clientSettings/register
clientSettings.register(list: { Entry })
Declare settings and actions, each naming the group it shows in. Each setting's value is applied at once. An entry declared again under its key replaces the earlier one.
Parameters
list{ Entry }— The entries:{ key, group, label, description?, field?, labels?, step?, format?, scope?, kept?, effect, button?, danger?, available? }. A setting names itsscope, or carrieskept = { get, set }when the system it configures keeps the person's choice.
globals/clientSettings/registerGroup
clientSettings.registerGroup(group: Group)
Declare a group of settings: one tab of the menu. A group declared again under its id replaces the earlier declaration and keeps its entries.
Parameters
groupGroup—{ id, title, description?, icon?, order?, visible? }.
globals/clientSettings/reset
clientSettings.reset(target: string)
Return a setting, or every setting of a group, to its default: the
person's choice is forgotten and the effect carried out with the default.
Refused, like set, with world or agent code behind it.
Parameters
targetstring— A setting's key, or a group's id.
clientSettings.reset("vr")
globals/clientSettings/run
clientSettings.run(key: string)
Run the action declared under key (recenter, enter VR, exit VR), as
its button in the menu does. Refused with world or agent code behind it.
Parameters
keystring— The action's key.
globals/clientSettings/set
clientSettings.set(key: string, value: any?)
Change the setting under key to value as the person's choice: the
value is held to the setting's field, kept in its scope, and its effect
carried out. The person's settings are changed by the engine: a call with
world or agent code behind it (on the stack, or behind the coroutine or
task it runs on) raises, naming the setting.
Parameters
keystring— The setting's dotted key.valueany(optional) — A value the setting's field takes.
clientSettings.set("xr.turn", "smooth")
globals/clientSettings/writable
clientSettings.writable() -> boolean
Whether a change made from here would be taken: true for the engine's own code, false with world or agent code behind the call: on the stack, or behind the coroutine or task it runs on.
Returns boolean — Whether set, reset and run would be taken.
modules/clientSettings/buildSection
buildSection(model: { [string]: any }): { [string]: any }
The System tab's widget tree, drawn from list(), in the room
model.width x model.height the app menu leaves it: the visible groups
as sections (down the side on a desktop and a headset's panel, across the
top on a phone) and the entries of the one chosen, each with its control,
and a way to put the group back to its defaults.
Parameters
model{ [string]: any }—{ width, height, presentation?, group?, groups? }:groupsis thelist()to draw, the current one when left out.
modules/clientSettings/close
close()
Close the app menu.
modules/clientSettings/get
get(key: string): any
The value of the setting under key: the one the person chose, or
the setting's default while they chose none.
Parameters
keystring— The setting's dotted key, e.g."xr.perspective".
local perspective = clientSettings.get("xr.perspective")
modules/clientSettings/install
install()
Follow the account the settings belong to and keep the System tab current while it is shown. Called once by the prelude.
modules/clientSettings/isOpen
isOpen(): boolean
Whether the app menu shows the System tab.
modules/clientSettings/list
list(): { GroupRow }
Every group declared, in its order, each with its entries: a
setting's value, default, where the value comes from ("player" once the
person chose one, "default" before), its scope, its choices or range,
and whether it can be used now; an action's button. A group's visible
says whether its tab shows on this client now. The settings menu draws
exactly this.
for _, g in clientSettings.list() do print(g.title, #g.entries) end
modules/clientSettings/onChanged
onChanged(fn: (key: string?, value: any) -> ()): () -> ()
Call fn(key, value) whenever a setting changes, and fn(nil) when
the account they belong to changes.
Parameters
fn(key: string?, value: any) -> ()— The listener.
Returns () — A function that stops the listener.
modules/clientSettings/open
open(group: string?)
Open the app menu on its System tab: over the window on desktop, as a world panel in front of the person in a headset. Every way in opens the same menu, a world's own pause tab included.
Parameters
groupstring?(optional) — The section to open on ("vr"), or the one shown last.
modules/clientSettings/reachable
reachable(): boolean
Whether some group of the settings shows on this client now. The System tab of the app menu and the editor's ways into it (its menu, the dock in a headset) show while one does.
modules/clientSettings/register
register(list: { Entry })
Declare settings and actions, each naming the group it shows in. Each setting's value is applied at once. An entry declared again under its key replaces the earlier one.
Parameters
list{ Entry }— The entries:{ key, group, label, description?, field?, labels?, step?, format?, scope?, kept?, effect, button?, danger?, available? }. A setting names itsscope, or carrieskept = { get, set }when the system it configures keeps the person's choice.
modules/clientSettings/registerGroup
registerGroup(group: Group)
Declare a group of settings: one tab of the menu. A group declared again under its id replaces the earlier declaration and keeps its entries.
Parameters
groupGroup—{ id, title, description?, icon?, order?, visible? }.
modules/clientSettings/reset
reset(target: string)
Return a setting, or every setting of a group, to its default: the
person's choice is forgotten and the effect carried out with the default.
Refused, like set, with world or agent code behind it.
Parameters
targetstring— A setting's key, or a group's id.
clientSettings.reset("vr")
modules/clientSettings/run
run(key: string)
Run the action declared under key (recenter, enter VR, exit VR), as
its button in the menu does. Refused with world or agent code behind it.
Parameters
keystring— The action's key.
modules/clientSettings/set
set(key: string, value: any)
Change the setting under key to value as the person's choice: the
value is held to the setting's field, kept in its scope, and its effect
carried out. The person's settings are changed by the engine: a call with
world or agent code behind it (on the stack, or behind the coroutine or
task it runs on) raises, naming the setting.
Parameters
keystring— The setting's dotted key.valueany(optional) — A value the setting's field takes.
clientSettings.set("xr.turn", "smooth")
modules/clientSettings/tab
tab(): { [string]: any }
The System tab of the app menu, as the built-in
menuTabs/system.menuTab hands it to the menu.
modules/clientSettings/writable
writable(): boolean
Whether a change made from here would be taken: true for the engine's own code, false with world or agent code behind the call: on the stack, or behind the coroutine or task it runs on.
typed/builtin//modules/api/engine/client_settings/clientSettings/buildSection
clientSettings.buildSection(model: { [string]: any }) -> { [string]: any }
The System tab's widget tree, drawn from list(), in the room
model.width x model.height the app menu leaves it: the visible groups
as sections (down the side on a desktop and a headset's panel, across the
top on a phone) and the entries of the one chosen, each with its control,
and a way to put the group back to its defaults.
Parameters
model{ [string]: any }—{ width, height, presentation?, group?, groups? }:groupsis thelist()to draw, the current one when left out.
Returns { [string]: any } — The widget tree.
typed/builtin//modules/api/engine/client_settings/clientSettings/close
clientSettings.close()
Close the app menu.
typed/builtin//modules/api/engine/client_settings/clientSettings/get
clientSettings.get(key: string) -> any
The value of the setting under key: the one the person chose, or
the setting's default while they chose none.
Parameters
keystring— The setting's dotted key, e.g."xr.perspective".
Returns any — The value; nil for a key no setting is declared under.
local perspective = clientSettings.get("xr.perspective")
typed/builtin//modules/api/engine/client_settings/clientSettings/isOpen
clientSettings.isOpen() -> boolean
Whether the app menu shows the System tab.
Returns boolean
typed/builtin//modules/api/engine/client_settings/clientSettings/list
clientSettings.list() -> { GroupRow }
Every group declared, in its order, each with its entries: a
setting's value, default, where the value comes from ("player" once the
person chose one, "default" before), its scope, its choices or range,
and whether it can be used now; an action's button. A group's visible
says whether its tab shows on this client now. The settings menu draws
exactly this.
Returns { GroupRow }.
for _, g in clientSettings.list() do print(g.title, #g.entries) end
typed/builtin//modules/api/engine/client_settings/clientSettings/onChanged
clientSettings.onChanged(fn: (key: string?, value: any) -> ()) -> () -> ()
Call fn(key, value) whenever a setting changes, and fn(nil) when
the account they belong to changes.
Parameters
fn(key: string?, value: any) -> ()— The listener.
Returns () -> () — A function that stops the listener.
typed/builtin//modules/api/engine/client_settings/clientSettings/open
clientSettings.open(group: string?)
Open the app menu on its System tab: over the window on desktop, as a world panel in front of the person in a headset. Every way in opens the same menu, a world's own pause tab included.
Parameters
groupstring(optional) — The section to open on ("vr"), or the one shown last.
typed/builtin//modules/api/engine/client_settings/clientSettings/reachable
clientSettings.reachable() -> boolean
Whether some group of the settings shows on this client now. The System tab of the app menu and the editor's ways into it (its menu, the dock in a headset) show while one does.
Returns boolean — Whether some group is visible.
typed/builtin//modules/api/engine/client_settings/clientSettings/register
clientSettings.register(list: { Entry })
Declare settings and actions, each naming the group it shows in. Each setting's value is applied at once. An entry declared again under its key replaces the earlier one.
Parameters
list{ Entry }— The entries:{ key, group, label, description?, field?, labels?, step?, format?, scope?, kept?, effect, button?, danger?, available? }. A setting names itsscope, or carrieskept = { get, set }when the system it configures keeps the person's choice.
typed/builtin//modules/api/engine/client_settings/clientSettings/registerGroup
clientSettings.registerGroup(group: Group)
Declare a group of settings: one tab of the menu. A group declared again under its id replaces the earlier declaration and keeps its entries.
Parameters
groupGroup—{ id, title, description?, icon?, order?, visible? }.
typed/builtin//modules/api/engine/client_settings/clientSettings/reset
clientSettings.reset(target: string)
Return a setting, or every setting of a group, to its default: the
person's choice is forgotten and the effect carried out with the default.
Refused, like set, with world or agent code behind it.
Parameters
targetstring— A setting's key, or a group's id.
clientSettings.reset("vr")
typed/builtin//modules/api/engine/client_settings/clientSettings/run
clientSettings.run(key: string)
Run the action declared under key (recenter, enter VR, exit VR), as
its button in the menu does. Refused with world or agent code behind it.
Parameters
keystring— The action's key.
typed/builtin//modules/api/engine/client_settings/clientSettings/set
clientSettings.set(key: string, value: any?)
Change the setting under key to value as the person's choice: the
value is held to the setting's field, kept in its scope, and its effect
carried out. The person's settings are changed by the engine: a call with
world or agent code behind it (on the stack, or behind the coroutine or
task it runs on) raises, naming the setting.
Parameters
keystring— The setting's dotted key.valueany(optional) — A value the setting's field takes.
clientSettings.set("xr.turn", "smooth")
typed/builtin//modules/api/engine/client_settings/clientSettings/writable
clientSettings.writable() -> boolean
Whether a change made from here would be taken: true for the engine's own code, false with world or agent code behind the call: on the stack, or behind the coroutine or task it runs on.
Returns boolean — Whether set, reset and run would be taken.