how to make a wait function
making the game wait a period of time before running the rest of the code
making the game wait a period of time before running the rest of the code
I think...
wait = function(t)
savedTime = system.time()
while system.time()-savedTime< t
system.time()
end
end
maybe..?
There is also builtin function called sleep
but that makes whole game wait if not called from specific thread like..
name_of_thread = do
//do code
sleep 2 seconds
//do the rest of code
end
//or
name_of_thread = sleep 1000 do //some code end
and you can control thread by doing
name_of_thread.pause()
name_of_thread.resume()
name_of_thread.stop()
I hope that I explained it good enough.
init = function()
after 5 seconds do
text = "Hello World"
color = "green"
end
text = "Wait"
color = "red"
end
update = function()
end
draw = function()
screen.clear()
screen.drawText( text, 0, 0, 30, color )
end