"Buildism warning: This game is using an unsupported scripting technique..."
#7
(07-23-2011, 02:24 PM)noob007 Wrote:
(07-23-2011, 02:22 PM)Duck Wrote:
(07-23-2011, 02:19 PM)noob007 Wrote:
(07-23-2011, 02:15 PM)Duck Wrote:
(07-23-2011, 01:47 PM)Jacob_ Wrote: Using sleep() for a period of time longer than 0.5 seconds in an event handler. It will give you a more detailed message in edit mode (if it's your game, of course.)


How are we meant to make things with delays if we can't use sleep?

Notice "in an event handler".

"How am I meant to put a ten second delay in my function if I can't use sleep?" Happy?

If said function is an event handler (callback), then use something like gameConfusedcheduleTask()

The preferred way is by using os.time(). It avoids the requirement of an extra thread.

[lua]
delay = 3 --3 seconds

lastCalled = os.time()
function doSomething()
if os.time() - lastCalled < delay then return end
--do stuff
lastCalled = os.time()
end
[/lua]
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)