Skip to main content

SettingDefinition

These settings definitions are used to define a setting and register them on both the client and server. See SettingDefinitionProvider for more details on grouping these.

Notably a setting is basically anything on the client that can be stored on the server by the client, and that relatively minimal validation is required upon. This can be both user-set settings, as well as very temporary data.

local SettingDefinition = require("SettingDefinition")

return require("SettingDefinitionProvider").new({
	LastTimeUpdateSeen = 0;
	LastTimeShopSeen = 0;
})

Functions

new

SettingDefinition.new(
settingNamestring,
defaultValueT
) → SettingDefinition<T>

Constructs a new setting definition which defines the name and the defaultValue

isSettingDefinition

SettingDefinition.isSettingDefinition(valueany) → boolean

Returns true if the value is a setting definition

Init

SettingDefinition:Init(serviceBagServiceBag) → ()

Initializes the setting definition from a service bag.

Get

SettingDefinition:Get(playerPlayer) → T

Gets the value for the given player

Set

SettingDefinition:Set(
playerPlayer,
valueT
) → ()

Sets the value

Promise

SettingDefinition:Promise(playerPlayer) → Promise<T>

Promise gets the value

PromiseSet

SettingDefinition:PromiseSet(
playerPlayer,
valueT
) → Promise<T>

Promise gets the value

Observe

SettingDefinition:Observe(playerPlayer) → Promise<T>

Promise gets the value

GetSettingProperty

SettingDefinition:GetSettingProperty(
serviceBagServiceBag,
playerPlayer
) → SettingProperty<T>

Gets a new setting property for the given definition

GetLocalPlayerSettingProperty

SettingDefinition:GetLocalPlayerSettingProperty(serviceBagServiceBag) → SettingProperty<T>

Gets a new setting property for the given definition

GetSettingName

SettingDefinition:GetSettingName() → string

Retrieves the default name of the setting

GetDefaultValue

SettingDefinition:GetDefaultValue() → T

Retrieves the default value for the setting

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructs a new setting definition which defines the name and the defaultValue",
            "params": [
                {
                    "name": "settingName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "defaultValue",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "SettingDefinition<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 43,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "Init",
            "desc": "Initializes the setting definition from a service bag.",
            "params": [
                {
                    "name": "serviceBag",
                    "desc": "",
                    "lua_type": "ServiceBag"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 62,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "Get",
            "desc": "Gets the value for the given player",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 79,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "Set",
            "desc": "Sets the value",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 92,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "Promise",
            "desc": "Promise gets the value",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 105,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "PromiseSet",
            "desc": "Promise gets the value",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 119,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "Observe",
            "desc": "Promise gets the value",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 132,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "isSettingDefinition",
            "desc": "Returns true if the value is a setting definition",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 145,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "GetSettingProperty",
            "desc": "Gets a new setting property for the given definition",
            "params": [
                {
                    "name": "serviceBag",
                    "desc": "",
                    "lua_type": "ServiceBag"
                },
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "SettingProperty<T>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 156,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "GetLocalPlayerSettingProperty",
            "desc": "Gets a new setting property for the given definition",
            "params": [
                {
                    "name": "serviceBag",
                    "desc": "",
                    "lua_type": "ServiceBag"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "SettingProperty<T>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 171,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "GetSettingName",
            "desc": "Retrieves the default name of the setting",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 181,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        },
        {
            "name": "GetDefaultValue",
            "desc": "Retrieves the default value for the setting",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 189,
                "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "SettingDefinition",
    "desc": "These settings definitions are used to define a setting and register them on both the client and server. See\n[SettingDefinitionProvider] for more details on grouping these.\n\nNotably a setting is basically anything on the client that can be stored on the server by the client, and that\nrelatively minimal validation is required upon. This can be both user-set settings, as well as very temporary\ndata.\n\n```lua\nlocal SettingDefinition = require(\"SettingDefinition\")\n\nreturn require(\"SettingDefinitionProvider\").new({\n\tLastTimeUpdateSeen = 0;\n\tLastTimeShopSeen = 0;\n})\n```",
    "source": {
        "line": 20,
        "path": "src/settings/src/Shared/Setting/SettingDefinition.lua"
    }
}