SettingDefinitionProvider
Provides settings in bulk, and can be initialized by a ServiceBag. See SettingDefinition for more details on how to use this.
tip
These settings providers should be used on both the client and the server. On the client, these are registered with the SettingsDataService so that they can be shown in UI automatically if desired.
On the server, these are registered with SettingsDataService and then are checked before arbitrary data can e sent.
local SettingDefinition = require("SettingDefinition")
return require("SettingDefinitionProvider").new({
KeyBinding = Enum.KeyCode.X;
CameraShake = true;
CameraSensitivity = 1;
})
Functions
new
Constructs a new provider with a list of SettingDefinition's.
-- In one location
local SettingDefinition = require("SettingDefinition")
return require("SettingDefinitionProvider").new({
KeyBinding = Enum.KeyCode.X;
CameraShake = true;
CameraSensitivity = 1;
})
Usage:
local ourSettings = serviceBag:GetService(require("OurSettings"))
print(ourSettings.CameraShake:Get(Players.LocalPlayer), true)
ourSettings.CameraShake:Set(Players.LocalPlayer, false)
ourSettings.CameraShake:Promise(Players.LocalPlayer)
:Then(function(cameraShake)
print(cameraShake)
end)
Init
Initializes the provider, storing the data in SettingsDataService
Start
SettingDefinitionProvider:
Start
(
) →
(
)
Starts the provider. Empty.
GetSettingDefinitions
Returns the setting definition
__index
You can index the provider to get a setting. For example
local SettingDefinition = require("SettingDefinition")
local provider = require("SettingDefinitionProvider").new({
KeyBinding = Enum.KeyCode.X;
CameraShake = true;
CameraSensitivity = 1;
})
local service = serviceBag:GetService(provider)
-- Write a setting
service.CamaraShake:GetLocalPlayerSettingProperty(serviceBag).Value = false
Get
Gets a new setting definition if it exists
Destroy
SettingDefinitionProvider:
Destroy
(
) →
(
)
Cleans up the setting registration