Skip to content

storage

Provides a way to persist data to the user’s storage drive, for use across Assetto Corsa sessions.

Define a layout of keys and default values. Accessing the returned table automatically manages disk input and output.

local settings = ac.storage({
uiVisible = true,
opacity = 0.8
})

ac.storage handles the heavy lifting of reading from and writing to the storage drive. Writes are debounced, meaning disk access is deferred for a few seconds and skipped entirely if no value change is detected. The storage system supports the following data types:

  • string
  • number
  • boolean
  • vec2, vec3, and vec4
  • rgb, and rgbm
ParameterTypeRequiredDescription
layouttable or stringYesEither a table of default values or a specific string key.
keyPrefixstringNoOptional prefix added to all keys in the storage table.

Using storage to remember the state of a UI checkbox.

-- define our persistent settings
local settings = ac.storage({
showMap = true
})
function script.windowMain()
-- checkbox updates the 'settings' table,
-- which triggers a disk save automatically
ui.checkbox("Show Minimap", settings.showMap)
if settings.showMap then
drawMyMap()
end
end