Fantasy computer for making, playing and sharing tiny games. · By Nesbox
How can my game wait or sleep for an amount of time?
'function TIC()' calls 60 times per second, so you can use code like this:
local t=0 function TIC() cls(12) t=t+1 -- wait 2 seconds if t<2*60 then return end print("HELLO WORLD!",84,64) end
Perfect, thanks mate
does this work on any other functions that arent function TIC? i want a custom fuction to play an animation
in case you don't have a stable frame rate as you can use this
local t=0 pt=time() dt=0 function TIC() dt=time()-pt pt=time() cls(12) t=t+dt -- wait 2000 miliseconds if t<2*1000 then return end print("HELLO WORLD!",84,64) end
um... waiting for music is refusing to work. I don't know why
Wow! it was that easy
Such a pity that javascript's setTimeout() doesn't function here...
async ={frames = 0}
function WaitForSeconds(secs)
async.frames = async.frames + 1;
if(async.frames >= secs * consts.maxFrames)then
async.frames = 0
return true
end -- if async
return false
end