Settings, input, and data
The three mechanisms serve different purposes:
| Mechanism | Use it for |
|---|---|
Config |
Settings exposed in the module UI. |
InputActions |
Buttons and other control actions. |
Storage |
Internal local data across module activations. |
Config: the user chooses a value
Section titled “Config: the user chooses a value”config.json contains a JSON array:
[ { "label": "Show status", "key": "ShowStatus", "type": "bool", "value": true }, { "label": "Text size", "key": "TextSize", "type": "number", "value": 18, "min": 12, "max": 32 }]if Config.ShowStatus then ImGui:DrawText( "Active", Rect.new(20, 20, 180, 40), Config.TextSize, Color.new(1, 1, 1), TextAnchor.MiddleLeft )endDo not use Config as storage. The game repopulates the table with saved settings after a UI change.
InputActions: the user presses a control
Section titled “InputActions: the user presses a control”inputs.json:
{ "Actions": [ { "Name": "ToggleStatus", "Type": "Button", "Binding": { "Path": "<Keyboard>/f8" } } ]}main.lua:
local action = InputActions:FindAction("ToggleStatus")local visible = true
if action ~= nil then action:OnPerformed(function() visible = not visible end)endCheck for nil: a mismatched name or invalid action definition is not found.
Storage: the module remembers state
Section titled “Storage: the module remembers state”if Storage.StatusVisible == nil then Storage.StatusVisible = trueend
local visible = Storage.StatusVisible
local function Toggle() visible = not visible Storage.StatusVisible = visibleendfalse is valid, so initialize with == nil rather than if not ....
What to send to a Reflex server
Section titled “What to send to a Reflex server”Config, InputActions, and Storage are client concerns. The server receives its own Config when loaded but cannot see client input or Storage.
Send a small validated table through Network when the server needs current client state.
See Config, InputAction, and Storage for complete formats.