systemSettings.module
This package holds more than this page lists. See all of its files in its world.
README.md
systemSettings
Which of several components stating one scene-wide system's settings is in force. A scene-wide system (screen-space reflections, ambient occlusion, depth of field, fog, exposure, environment lighting, weather, ...) runs under one set of settings, and more than one component instance can state them at once: two hosts in one scene, an instance and the one replacing it while a script reloads, or the instances a scene module's builder makes while it records a rebuild beside the ones its last build placed.
Each component instance takes a claim on the system and states its settings through it every frame:
local Ssr = require("@builtin::systems.reflections.ssr")
local systemSettings = require("@builtin::modules.systemSettings")
local claim = systemSettings.claim("@builtin::systems.reflections.ssr", {
push = Ssr.set, -- puts the settings in force
release = Ssr.clear, -- takes the system down
live = Ssr.active, -- whether the system is up
})
function update(_dt)
claim:state(signatureOf(opts()), opts())
end
function onDestroy()
claim:release()
end
What is in force
The claims on one system are kept in the order they last stated something new, and the newest is in force.
- A claim whose settings changed moves to the newest place and pushes them: the last component edited wins.
- A claim that joins stating exactly what is in force takes the newest place and pushes nothing.
- Releasing a claim while others are live hands the system to the newest of them, which pushes its own settings when they differ. Only the last claim released takes the system down.
- The claim in force pushes again when the system it brought up is no longer
up (a script's
clear(), a feature torn down from outside), so a component standing in the scene keeps its system running. A push that left the system down, such as a setting that turns it off, is not repeated.
A world's default
A system every world runs by default holds a fallback
(systemSettings.fallback): the settings it runs with while no component
states it. The fallback sits under every claim. A claim that states takes the
system over at once, and the last claim released hands the system back to the
fallback instead of taking it down. The fallback pushes only when it states
settings other than the ones in force, so a script's own clear() stays in
force until the fallback states something new or a claim comes and goes.
Exports
systemSettings.claim(key, spec) -> Claim: a claim on the system namedkey(the path of the module that drives it).spec.push(opts)puts settings in force,spec.release()takes the system down, and the optionalspec.live()says whether it is up.claim:state(sig, opts): state the settings for this frame.sigis a string that differs wheneveroptsdoes.claim:release(): let the system go, fromonDestroy.systemSettings.fallback(key, spec) -> Claim: the system's fallback, with the same spec and methods as a claim;stateit with the settings it holds andreleaseit to take it away.claim:inForce() -> boolean: whether this claim's settings are in force.systemSettings.holder(key) -> string?: theownerof the claim in force, the fallback's while no claim stands.systemSettings.count(key) -> number: how many live claims state the system.