This maybe and easy question but I've been playing around with a new code I wrote for my QuestCounter. My counter when double clicked will show 1, 2, 3, and so on. So someone can count how many quest they've done. I also have the mouse wheel when moved to reset it back to 0 and a slash command to hide it if you want. Now I have it where if you reloadui or logout it will remember where the location of the addon is and put it back so you don't have to keep moving it around. My question comes in on this example. If I have clicked my QuestCounter and have it saying Completed: 7 when I reload the ui it will set back to QuestCounter which is the original text. What I want it to do is if I logout and it says Completed: 7 when I log back in it will still say Completed: 7 . Here is my code below.
txt
Lua Code:
## APIVersion: 100009
## Title: |cFFFFB0QuestCounter|r 1.0
## Description: QuestCounter is just a simple counter that you can use to count the quest you've done.
## Author: |c00C000Zireko
## Version: 1.0
## SavedVariables: Cou_Variables
QuestCounter.xml
QuestCounter.lua
xml
Lua Code:
<GuiXml>
<Controls>
<TopLevelControl name="QuestCounter" clampedToScreen="true" mouseEnabled="true" movable="true" resizeToFitDescendents="true" hidden="false">
<Controls>
<Label name="$(parent)Count" font="ZoFontBookScroll" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" horizontalAlignment="CENTER" text="QuestCounter">
<Anchor point="CENTER" />
</Label>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>
lua
Lua Code:
--Still trying to figure out how to save the clicked count so on relog or reload it holds how many quest you've double clicked for.
local SV
local defaults = {
["Count"] = {
["offsetx"] = 0,
["offsety"] = 0,
["point"] = CENTER,
["relPoint"] = CENTER,
["ClickedCount"] = 0,
},
}
local ClickedCount = 0
local function ClickCount()
ClickedCount = ClickedCount + 1
QuestCounterCount:SetText("Completed: "..ClickedCount)
end
local function ResetCount()
ClickedCount = 0
QuestCounterCount:SetText("QuestCounter")
end
local function OnMoveStop(self)
local valid, point, _, relPoint, offsetx, offsety = self:GetAnchor(0)
if valid then
SV.Count.point = point
SV.Count.relPoint = relPoint
SV.Count.offsetx = offsetx
SV.Count.offsety = offsety
SV.Count.ClickedCount = ClickedCount
end
end
local function OnAddOnLoaded(eventCode, addon)
if addon == "QuestCounter" then
EVENT_MANAGER:UnregisterForEvent("QuestCounter", EVENT_ADD_ON_LOADED)
SV = ZO_SavedVars:New("Cou_Variables", 2, nil, defaults)
QuestCounter:SetAnchor(SV.Count.point, nil, SV.Count.relPoint, SV.Count.offsetx, SV.Count.offsety)
QuestCounter:SetHandler("OnMoveStop", OnMoveStop)
QuestCounter:SetHandler("OnMouseDoubleClick", ClickCount)
QuestCounter:SetHandler("OnMouseWheel", ResetCount)
SLASH_COMMANDS["/qlc"] = function()
QuestCounter:ToggleHidden()
end
end
end
EVENT_MANAGER:RegisterForEvent("CountCounter", EVENT_ADD_ON_LOADED, OnAddOnLoaded)