-
Notifications
You must be signed in to change notification settings - Fork 79
Working with Settings
Redmew supports setting and saving settings. For self-hosted solutions without server, this is stored per game. When playing on a Redmew hosted game it will be synced to the server and thus to other Redmew games running.
To add a custom setting you have to require the utility that lets you get and set them:
local Settings = require 'utils.redmew_settings'
Once you have this imported, you can register your custom settings:
local Settings = require 'utils.redmew_settings'
-- example
local name = 'toast-volume' -- this name will be how you call get(), set() and unset()
local type = Settings.types.fraction -- defines the storage type, fraction is between 0 and 1
local default = 1.0 -- the default value when a player hasn't set this before
local localisation_key = 'toast.toast_volume_setting_label' -- used for translations
Settings.register(name, setting_type, default, localisation_key)
By registering the setting you can now use get()
, set()
and unset()
to control the value.
-- get the setting
Settings.get(player.index, 'toast-volume')
-- set it
Settings.set(player.index, 'toast-volume', 0.5)
-- remove it for this player and fall back to the default
Settings.unset(player.index, 'toast-volume')
When a setting is changed, an event is fired; Settings.events.on_setting_set
and contains data that can be used to update things in the scenario. Current usage examples:
- When a setting updates outside of the settings GUI, it will also update the value in this GUI to reflect the current state
- When a setting changes (regardless of where), the setting synchronization to the server will try to save it on the remote server
By default the scenario provides GUI to modify settings and will include things like error messages if input is invalid. You can add custom types in resources/setting_types.lua
.
Having issues? Reach out on discord
Got a bug report, feature request or map idea? Open an issue
Looking to download maps? See releases or the public save directory
Interested in Localization? Check out the progress at Crowdin