Thread Tools Display Modes
Prev Previous Post   Next Post Next
05/03/14, 03:14 PM   #1
Zierk
 
Zierk's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 10
Help with savedVars and movable frames

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:
  1. -- save frame location after moving
  2. function pOnMoveStop()
  3.   local name = Postmaster:GetName()
  4.   local left = Postmaster:GetLeft()
  5.   local top = Postmaster:GetTop()
  6.  
  7.   if name == "" or name == nil then return end --debug line
  8.   d("Position of "..name.." frame saved to "..left.."X, "..top.."Y.") --debug line
  9.   savedVars.frameX = left
  10.   savedVars.frameY = top
  11.  
  12. end
  13.  
  14. -- init default values
  15. local defaults =
  16. {
  17.   frameX = 100,
  18.   frameY = 200,
  19. }
  20.  
  21. -- Initalizing the addon
  22. local function pInitialize( eventCode, addOnName )
  23.  
  24.   if ( addOnName ~= "Postmaster" ) then return end
  25.  
  26.  
  27.   -- Get savedVars or set defaults
  28.   savedVars = ZO_SavedVars:NewAccountWide("Postmaster_SavedVariables", Postmaster.version, nil, defaults)
  29.  
  30.   --Postmaster:ClearAnchors()
  31.   Postmaster:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, savedVars.frameX, savedVars.frameY)
  32. 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.

Last edited by Zierk : 05/03/14 at 03:44 PM. Reason: correct typo
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Help with savedVars and movable frames


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off