Lightweight library providing saved variables functionality.
What we have:
- installation wide saved variables
- the most flat structure
- convenient access to the saved variable of other servers, accounts, characters
What we have not:
- ZO_SavedVars
- namespaces
- profiles
- wildcards
Usage:
Add dependency:
Code:
## DependsOn: LibSimpleSavedVars
## SavedVariables: MyAddonData
Code:
Code:
-- installation wide saved variables
self.data = LibSimpleSavedVars:NewInstallationWide("MyAddonData", 1, {
items = {},
})
-- server wide saved variables
self.data = LibSimpleSavedVars:NewServerWide("MyAddonData", 1, {
items = {},
})
-- account wide saved variables
self.data = LibSimpleSavedVars:NewAccountWide("MyAddonData", 1, {
items = {},
})
-- character wide saved variables
self.data = LibSimpleSavedVars:NewCharacterWide("MyAddonData", 1, {
items = {},
})
self.data.items[15] = true
self.data.items[27] = true
Retrieving other saved variables:
Code:
self.data = LibSimpleSavedVars:NewCharacterWide("MyAddonData", 1, {
items = {},
characterName = nil
})
self.data.characterName = GetUnitName("player")
self.data.items[15] = true
self.data.items[27] = true
for characterId, characterData in pairs(LibSimpleSavedVars:GetAccountData("MyAddonData")) do
local characterName = characterData.characterName
local characterItems = characterData.items
-- ...
end
API:
Code:
LibSimpleSavedVars:NewInstallationWide(name, version [, defaults])
LibSimpleSavedVars:NewServerWide(name, version [, defaults])
LibSimpleSavedVars:NewAccountWide(name, version [, defaults])
LibSimpleSavedVars:NewCharacterWide(name, version [, defaults])
LibSimpleSavedVars:GetInstallationData(name)
LibSimpleSavedVars:GetServerData(name [, server])
LibSimpleSavedVars:GetAccountData(name [, server [, displayName]])
LibSimpleSavedVars:GetCharacterData(name [, server [, displayName [, characterId]]])
LibSimpleSavedVars.NA
LibSimpleSavedVars.EU
LibSimpleSavedVars.PTS
Defaults:
Code:
server = GetWorldName()
displayName = GetDisplayName()
characterId = GetCurrentCharacterId()