I've tried finding the solution to my issue using these threads already:
http://www.esoui.com/forums/showthread.php?t=1173
http://wiki.esoui.com/AddOn_Quick_Questions
Basically I am trying to save a movable frame's location across logouts and reloaduis using a saved variables file.
My code looks like this:
In MyAddon.txt
Code:
## SavedVariables: Postmaster_SavedVariables
Lua Code:
-- save frame location after moving
function pOnMoveStop()
local name = Postmaster:GetName()
local left = Postmaster:GetLeft()
local top = Postmaster:GetTop()
if name == "" or name == nil then return end --debug line
d("Position of "..name.." frame saved to "..left.."X, "..top.."Y.") --debug line
savedVars.frameX = left
savedVars.frameY = top
end
-- init default values
local defaults =
{
frameX = 100,
frameY = 200,
}
-- Initalizing the addon
local function pInitialize( eventCode, addOnName )
if ( addOnName ~= "Postmaster" ) then return end
-- Get savedVars or set defaults
savedVars = ZO_SavedVars:NewAccountWide("Postmaster_SavedVariables", Postmaster.version, nil, defaults)
--Postmaster:ClearAnchors()
Postmaster:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, savedVars.frameX, savedVars.frameY)
end
The issue, is that the default values will overwrite the saved values from the OnMoveStop function when I reloadui. I do not know how to initialize the saved Vars file without including the default values to avoid having a nil value error.