I have completed the tutorials on the wiki, and am not practicing making them from scratch without looking at the tutorials (just my notes and references). I got my addon to display the d("Entering") and d("Exiting") combat as well as show the popup window "ENGAGED" in red. Now I am trying to figure out the savedVariables but I am running into a bit of trouble. I opened up the savedVariables tutorial and pulled out as much info as I could from it, but my addon still doesn't want to remember where it was on reload. Can somebody take a look please?
Addon Structure
Addons/PhilsCombatIndicator/
->PhilsCombatIndicator.txt
->PhilsCombatIndicator.xml
->PhilsCombatIndicator.lua
Text File
Code:
## Title: Phils Combat Indicator
## Description: Displays Combat State
## APIVersion: 100010
## Version: .1
## SaveVariables: PhilsCombatIndicatorVariables
PhilsCombatIndicator.xml
PhilsCombatIndicator.lua
Xml File
Code:
<GuiXml>
<Controls>
<TopLevelControl name="PhilsCombatIndicatorWindow" movable="true" mouseEnabled="true" hidden="false">
<Dimensions x="300" y="50"/>
<Anchor point="TOPLEFT" relativeTo="GuiRoot" relativePoint="CENTER" offsetX="0" offsetY="0"/>
<OnMoveStop>
PhilsCombatIndicator.SaveLoc()
</OnMoveStop>
<Controls>
<Label name="$(parent)Label" width="300" height="50" font="ZoFontWinH1" inheritAlpha="true" color="FF0000"
wrapMode="TRUNCATE" verticalAlignment="TOP" horizontalAlignment="CENTER" text="ENGAGED">
<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT"/>
</Label>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>
Lua File
Lua Code:
PhilsCombatIndicator = {}
PhilsCombatIndicator.name = "PhilsCombatIndicator"
PhilsCombatIndicator.Default = {
offsetX = 20,
offsetY = 75
}
function PhilsCombatIndicator.SaveLoc()
PhilsCombatIndicator.savedVariables.offsetX = PhilsCombatIndicatorWindowLabel:GetLeft()
PhilsCombatIndicator.savedVariables.offsetY = PhilsCombatIndicatorWindowLabel:GetTop()
end
function PhilsCombatIndicator.OnCombat(event, inCombat)
d("OnCombat Called")
if inCombat then
d("Entering Combat")
PhilsCombatIndicatorWindow:SetHidden(false)
else
d("Leaving Combat")
PhilsCombatIndicatorWindow:SetHidden(true)
end
d("OnCombat Ending")
end
function PhilsCombatIndicator.Initialize(event, addonName)
if addonName == PhilsCombatIndicator.name then
PhilsCombatIndicator.savedVariables = ZO_SavedVars:New("PhilsCombatIndicatorVariables", 1, nil, PhilsCombatIndicator.Default)
EVENT_MANAGER:RegisterForEvent(PhilsCombatIndicator.name, EVENT_PLAYER_COMBAT_STATE, PhilsCombatIndicator.OnCombat)
PhilsCombatIndicatorWindow:ClearAnchors()
PhilsCombatIndicatorWindow:SetAnchor(TOPLEFT, GuiRoot, CENTER, PhilsCombatIndicator.savedVariables.offsetX, PhilsCombatIndicator.savedVariables.offsetY)
EVENT_MANAGER:UnregisterForEvent(PhilsCombatIndicator.name, EVENT_ADD_ON_LOADED)
else
return
end
end
EVENT_MANAGER:RegisterForEvent(PhilsCombatIndicator.name, EVENT_ADD_ON_LOADED, PhilsCombatIndicator.Initialize)