mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
20 lines
321 B
Text
20 lines
321 B
Text
|
local function interval(s)
|
||
|
local pin
|
||
|
|
||
|
local function throttle()
|
||
|
if not pin then
|
||
|
pin = os.clock()
|
||
|
end
|
||
|
|
||
|
local elapsed = os.clock() - pin > s
|
||
|
if elapsed then
|
||
|
pin = os.clock()
|
||
|
end
|
||
|
|
||
|
return elapsed
|
||
|
end
|
||
|
return throttle
|
||
|
end
|
||
|
|
||
|
return interval
|