[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Sleep
- From: Steven Johnson <steve@...>
- Date: Wed, 13 Oct 2010 13:58:56 -0500
On Wed, Oct 13, 2010 at 12:29 PM, Daniel Aquino
> Wouldn't that be busy ?
> On Wed, Oct 13, 2010 at 1:26 PM, Gabriel Duarte <firstname.lastname@example.org>
>> Try out
>> function sleep(length)
>> local start = os.clock()
>> while os.clock() - start < length do end
>> On Wed, Oct 13, 2010 at 2:20 PM, Henning Diedrich <email@example.com>
>>> Hi list,
>>> is there a sleep function that is
>>> - non-busy
>>> - allows for ctrl-C
>>> - doesn't get stuck
>>> - does not require a C extension
Can you run your game tick in a coroutine? If so, you can mitigate the
busy-ness of the loop by interspersing yield() calls.
I do have code for this, but I'm afraid it's no longer simple (chronic
"framework madness"...) and not in rock form. For basic needs, though,
it ought to be sufficient to just extend Gabriel's example.