So after three days of learning how to use lua and xml, I'm still very much lost when it comes to actually creating something of my own.
What I'm trying to do is create a 10min timer (doesn't matter whether its counting up or down). I'm currently working with seconds as minutes seem a bit complicated as I think i'd have to display the active conversion of minutes from seconds, which itself is already out of my present abilities.
At the moment, I have a functional counter synced to GetFrameDeltaTimeSeconds() every time my addon updates however, GetFrameDeltaTimeSeconds() seems to be 3x the speed of actual seconds on a clock. It's still better than updating every frame but it still isn't what I want it to be.
My current codes are:
Timer.lua
Lua Code:
local counter = 0
local delta = GetFrameDeltaTimeSeconds()
function TimerUpdate()
TimerCounter:SetText(string.format("Timer: %0.2fs", counter))
counter = counter + delta
end
function TimerInitalized()
end
Timer.xml
Code:
<GuiXml>
<Controls>
<TopLevelControl name="Timer">
<Dimensions x="200" y="42" />
<Anchor point="CENTER" />
<OnUpdate>
TimerUpdate()
</OnUpdate>
<OnInitialized>
TimerInitialized()
</OnInitialized>
<Controls>
<Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
<Label name="$(parent)Counter" font="ZoFontWindowTitle" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="Timer: ">
<AnchorFill />
</Label>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>
Also I wouldn't even know how to get it to stop once it reached 600secs (10 mins).
In pure Lua it would look something like this:
Lua Code:
function sleep(s)
local atime = os.time() + s
repeat until os.time() > atime
end
Time = 0
for i=Time, 599 do
print (i + 1)
sleep(1)
end
However, I don't know how to even implement something like that into ESO.
All help is appreciated.
Thanks in advance!