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:
function init( eventCode, addOnName )
if ( addOnName ~= Addon.name ) then
return
end
Addon.defaults = {
offsetx=30,
offsety=1000
}
Addon.SV = ZO_SavedVars:New( "Addon_SV" , math.floor( Addon.version * 100 ) , nil , Addon.defaults, nil )
AddonUI:SetAnchor( TOPLEFT, GuiRoot, TOPLEFT, Addon.SV.offsetx , Addon.SV.offsety )
end
EVENT_MANAGER:RegisterForEvent( "Addon" , EVENT_ADD_ON_LOADED , init )
function Addon.SaveVars( self )
Addon.SV.offsetx = self:GetLeft()
Addon.SV.offsety = self:GetTop()
end