Thread Tools Display Modes
04/06/14, 01:04 PM   #1
Sharp
 
Sharp's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 32
Error when trying to Save Variables

Hey all,

I am getting an error when trying to call a function in the OnMoveStop event trying to save variables.

Code:
Error: 4857935691701591531:3: attempt to index a nil value
stack traceback:
	4857935691701591531:3: in function '(main chunk)'|r
Code:
<GuiXml>
    <Controls>
        <TopLevelControl name="AddonUI" movable="true" mouseEnabled="true" clampedToScreen="true">
            <Dimensions x="180" y="35" />
            <Anchor point="TOPLEFT" offsetX="0" offsetY="0" /> 
			<OnMoveStop>
				Addon.SaveVars( self )
			</OnMoveStop>
            <OnUpdate>
               Update()
            </OnUpdate>			
			<OnMouseEnter>
				DisplayItems()
			</OnMouseEnter>
			<OnMouseExit>
				hideItems()
			</OnMouseExit>
            <Controls>
                <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
                <Label name="$(parent)_Label" font="ZoFontGame" color="FFFFFF" wrapMode="ELLIPSIS" horizontalAlignment="CENTER" verticalAlignment="CENTER" text="TEST">
                    <AnchorFill />
                </Label>
            </Controls>
        </TopLevelControl>
    </Controls>
</GuiXml>
Lua Code:
  1. function init( eventCode, addOnName )
  2.  
  3.     if ( addOnName ~= Addon.name ) then
  4.         return
  5.     end
  6.    
  7.     Addon.defaults = {
  8.         offsetx=30,    
  9.         offsety=1000
  10.     }
  11.    
  12.     Addon.SV = ZO_SavedVars:New( "Addon_SV" , math.floor( Addon.version * 100 ) , nil , Addon.defaults, nil )
  13.  
  14. AddonUI:SetAnchor( TOPLEFT, GuiRoot, TOPLEFT, Addon.SV.offsetx , Addon.SV.offsety )
  15.    
  16. end
  17.  
  18. EVENT_MANAGER:RegisterForEvent( "Addon" , EVENT_ADD_ON_LOADED , init )
  19.  
  20. function Addon.SaveVars( self )
  21.     Addon.SV.offsetx = self:GetLeft()
  22.     Addon.SV.offsety = self:GetTop()
  23. end

Last edited by Sharp : 04/06/14 at 01:06 PM.
  Reply With Quote
04/06/14, 01:25 PM   #2
Sharp
 
Sharp's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 32
Figured it out.

I just took away Addon.

Code:
Addon.SaveVars( self )
I don't know why it errored out.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Error when trying to Save Variables

Thread Tools
Display Modes

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