Solarus-Games English Forum

Solarus => Development => Topic started by: Zefk on May 18, 2016, 10:35:25 PM

Title: How to pause a script for a certain amount of time? (Solved)
Post by: Zefk on May 18, 2016, 10:35:25 PM
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
Title: Re: How to pause a script for a certain amount of time?
Post by: Diarandor on May 18, 2016, 11:06:34 PM
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.
Title: Re: How to pause a script for a certain amount of time?
Post by: Christopho on May 18, 2016, 11:08:59 PM
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.
Title: Re: How to pause a script for a certain amount of time?
Post by: Zefk on May 18, 2016, 11:24:50 PM
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!