Here is another method. This one uses two timers.
The first timer called print_timer acts as the loop and prints the event.name and event.time to the console.
The second timer called speed_timer is used to gradually decrease the delay in print_timer causing it to fire events faster.
local print\_timer = nil local speed\_timer = {speed = 1010} local function handle\_print\_timer(event) print(event.name.." "..event.time) end local function handle\_speed\_timer(event) speed\_timer.speed = speed\_timer.speed - 10 if speed\_timer.speed \<=0 then timer.cancel(speed\_timer["timer"]) speed\_timer["timer"] = nil speed\_timer.speed = 1 print("Maximum speed set") end if print\_timer ~= nil then timer.cancel(print\_timer) print\_timer = nil end print\_timer = timer.performWithDelay(speed\_timer.speed, handle\_print\_timer, 1000) print("Speed changed to: "..speed\_timer.speed) end speed\_timer["timer"] = timer.performWithDelay(2000, handle\_speed\_timer, 1000 )
In the code I have set a maximum iterations for each timer. This is only so it didn’t run constantly during testing.
The speed timer is set to change the speed every 2 seconds.
The print timer begins printing events at a rate of 1 per second. So you will see two printed timer events between speed changes until the delay drops to about 650. Then the print timer will start printing 3 events for every speed change. And then obviously this grows as the delay drops.
When the delay drops below 0, I set the print timer speed to 1 and remove the speed timer. This will give you maximum speed from the timer.