ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Error when trying to Save Variables (https://www.esoui.com/forums/showthread.php?t=636)

Sharp 04/06/14 01:04 PM

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

Sharp 04/06/14 01:25 PM

Figured it out.

I just took away Addon.

Code:

Addon.SaveVars( self )
I don't know why it errored out.


All times are GMT -6. The time now is 02:07 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI