Page 1 of 1

Async able Countdown

Posted: Wed Jan 12, 2022 4:57 pm
by S1N74X
For my current Project i have fiddlet togehter a callable Countdown which can be launched async.
Maybe it is usefull for someone.

Thanks @ShyTwig16 for the idea of a threaded approach

Code: Select all

{$lua}
if syntaxcheck then return end
[ENABLE]

local function asyncTimer(count,text)
    local start = os.clock()
    local current = 0
    while current < count do
    current = os.clock() - start
    --print(current)
    end
    speakEnglish(text)
	return true
end

function countDown(count,text)
 createThread(function(thread)
	if asyncTimer(count,text) then
    thread.Destroy()
	end
end)
end

countDown(30,'expired')

[DISABLE]

Re: Async able Countdown

Posted: Wed Jan 12, 2022 5:32 pm
by LeFiXER
Good work! Although this should be in the Lua section.

Re: Async able Countdown

Posted: Wed Jan 12, 2022 5:47 pm
by S1N74X
LeFiXER wrote:
Wed Jan 12, 2022 5:32 pm
Good work! Although this should be in the Lua section.
Thank you.
Oh ok, i read "Helpers" so i thought this will be the right Section :)
If it disturbs here an Admin can move the Topic maybe.

Re: Async able Countdown

Posted: Thu Jan 13, 2022 5:33 am
by LeFiXER
No harm done :)