For the nil value error, make sure that the number being acted on is in scope and has been initialised.
A timer will only use the interval you first give it. The two choices are to cancel and restart the timer with the new value, or use an enterFrame listener to make your own timer.
local delayRate = 3000 local lastIterationTime = system.getTimer() local myDecreasingRateFunction = function (delayRate) print ("Running after "..delayRate.." ms delay"); end local gameLoop = function () if (system.getTimer() - lastIterationTime \>= delayRate) then lastIterationTime = system.getTimer() myDecreasingRateFunction(delayRate) delayRate = delayRate - 200 end end Runtime:addEventListener("enterFrame", gameLoop)
Well the error tells you exactly what’s wrong - one of the variables involved in a calculation is not a number, but a string. If you know the line number then you know which variables to check. Make sure you’re not using the same name for two different things and overwriting a number with a string, or using the wrong name somewhere.