initSettings
Definition
-- @/lua/ge/extensions/core/settings/settings.lua:400
local function initSettings(reason)
-- fix the options up and combine the keys and values into the dict
for k,v in pairs(options) do
if v.keys and v.values and not v.dict then
v.dict = {}
for i = 0, tableSizeC(v.keys) - 1 do
v.dict[v.keys[i]] = v.values[i]
end
end
end
-- build option helpers
extensions.load({"core_settings_graphic","core_settings_audio","core_settings_rally"})
tableMerge(options, core_settings_graphic.buildOptionHelpers())
tableMerge(options, core_settings_audio.buildOptionHelpers())
tableMerge(options, core_settings_rally.buildOptionHelpers())
-- add C++ propagation wherever possible
for k,v in pairs(M.impl.defaults) do
if CppSettings[k] ~= nil then -- check if C++ side cares about this setting
options[k] = options[k] or {}
if options[k].set == nil then
-- no setter is defined, add one that propagates the value to C++ side
options[k].set = function(value)
if type(CppSettings[k]) == type(value) then
CppSettings[k] = value
else
log("E", "", string.format("Unable to parse setting '%s': it should be a %s, but is a %s. The ignored value is: %s", k, type(CppSettings[k]), type(value), dumps(value)))
end
end
else
-- a setter was already defined, cannot add a setter to propagate value to C++ side
log("E", "", string.format("Unable to propagate setting '%s' to C++ side, since it already has a custom setter in LUA side: this is likely a conflict of intentions that requires bugfixing", k))
end
end
end
-- load the persistency file at least
local data = loadSettingValues()
tableMerge(values, data)
core_settings_graphic.onInitSettings(values)
end
Callers
@/lua/vehicle/extensions/vehicleStatsLogger.lua
local function initSettings()
settings.outputDir = "VSL"
initStatsRecord()
initSettings()
guihooks.trigger("LoadedVehicleStatsLogger")
@/lua/ge/main.lua
function init(reason)
settings.initSettings(reason)
@/lua/ge/extensions/gameplay/rally/loop/rallyLoopManager.lua
-- Initialize settings
self:initSettings()
-- init settings with the loop manager so they cant be changed during the loop
function C:initSettings()
self.resetBudget = settings.getValue('rallyLoopResetBudget')