Returns the value of a setting in a mod.
Syntax
GetSetting( setting_name, [mod_name] )Arguments
- setting_name (string): The name of the setting to get the value of.
- mod_name (string): The mod you want to get the setting from from.
- Optional, defaults to the mod that called the function.
Return Values
- (boolean | integer | number | string | nil): The value of the setting.
- The type depends on the
Typeof the[Setting]. - Returns
nilif the setting does not exist or no such mod is loaded.
- The type depends on the
Examples
-- Get the difficulty setting of the current mod.
local Difficulty = GetSetting("Difficulty")
-- Check some other setting in another mod.
local SomeOtherSetting = GetSetting("SomeOtherSetting", "AnotherMod")Version History
Version 1.23.10
Fixed an issue where the GetSetting and GetSettings functions read the low 32-bits of the 64-bit signed integer setting values as unsigned and casted that to a 64-bit signed integer to give it to Lua. This caused negative integer setting values to wrap as if they were 32-bit unsigned values.
Version 1.13
Made the GetSetting function return nil instead of throwing an error if a setting doesn't exist. Mod creators should do checks for nil on UncompiledOnly settings.
Version 1.12.1
Fixed a bug where using the GetSetting function on an Integer type Number setting would return a number.