Posted: Tue May 14, 2024 6:06 am Post subject: Timer Loop Duration
I know this has been asked multiple times before. But I couldn't find it.
I am modifying the GUI and moving the Hex checkbox somewhere else however at that location other things move too so I have to adjust accordingly.
The other supposed solution is this but it only affects what I declared and overlooks the original instructions at this event.
Code:
getMainForm().VarType.OnMouseMove = function()
...
end
This code will result in stack-over-flow
Code:
getMainForm().VarType.OnMouseMove = function()
local duration = 10 --(1 * 60)
local startTime = os.clock()
fixHexBoxPostimer = fixHexBoxPostimer or createTimer()
fixHexBoxPostimer.Interval = 100
fixHexBoxPostimer.OnTimer = function(t)
if os.clock() - startTime < duration then
MainForm.cbHexadecimal.Top = MainForm.cbNot.Top
--print("Code on")
else
fixHexBoxPostimer.Destroy()
--print("Code off")
end
end
end
So, obviously, I am looking for a way to check if the duration is up to break the loop.
Sorry that I am bothering you with things but I am trying to learn Lua by messing up things
Thank you for understanding.
I don't have any idea how the createTimer() works under the hood if you have an idea I'd be pleased. I know I could look it up in the source code. Well, I can't understand Pascal
With "MouseMove" the function will be triggered repeatedly as the mouse arrow moves over the relevant surface.
Use "MouseEnter" or something else instead.
Code:
local duration = 0
if fixHexBoxPostimer then fixHexBoxPostimer.Destroy() end
fixHexBoxPostimer = createTimer(MainForm,false)
fixHexBoxPostimer.Interval = 100
fixHexBoxPostimer.OnTimer = function()
duration = tonumber(duration) + 1
if duration==10 then
MainForm.cbHexadecimal.Top = MainForm.cbNot.Top
--print("Code on")
fixHexBoxPostimer.Enabled=false
end
end
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum