How to pause a script for a certain amount of time? (Solved)

Started by Zefk, May 18, 2016, 10:35:25 PM

Previous topic - Next topic
Is there something similar to socket.sleep(0.0004). I would like to pause my script for 0.4 milliseconds.  This will loop around and around for a time system.

Code ( lua) Select

socket.sleep(0.0004)
--One second in real time is about 1 minute in game time.
--0.4 milliseconds waits for about 6 frames at 15 frames per second.

6/15 = 0.4 milliseonds

May 18, 2016, 11:06:34 PM #1 Last Edit: May 18, 2016, 11:10:23 PM by Diarandor
Just use timers, they are a great tool.

Whoops, timers will not work for less than 1 millisecond. Or you mean 0,4 seconds?
Maybe it is not possible.

EDIT: I think what you need is 0,4 seconds, which is 400 milliseconds. If that's the case, you can use timers.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Do you want to completely freeze the simulation for 0.4 ms? To what end?
0.4 ms is much smaller than the timestep of the main loop.

Maybe my calculations are off....basically....I want 24 minutes to be one day in game time and the ability to be able to tweak it for realtime. Otherwise.....realtime will only be possible with the script I am planning unless I tweak the variables or add a millisecond variable.
Script link:
http://forum.solarus-games.org/index.php/topic,624.msg3168.html#msg3168

Edit: Found the solution. Thanks!