lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Oct 13, 2010 at 12:29 PM, Daniel Aquino
<mr.danielaquino@gmail.com> wrote:
> Wouldn't that be busy ?
>
> On Wed, Oct 13, 2010 at 1:26 PM, Gabriel Duarte <confusosk8@gmail.com>
> wrote:
>>
>> Try out
>> function sleep(length)
>>     local start = os.clock()
>>
>>     while os.clock() - start < length do end
>> end
>> On Wed, Oct 13, 2010 at 2:20 PM, Henning Diedrich <hd2010@eonblast.com>
>> wrote:
>>>
>>> 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.