Does anyone actually need to use sleep() in an event handler?
#1
Star 
Disabling sleep() in events would solve a whole lot of issues and confusing things about scripting (having to use gameConfusedcheduleTask() when creating a model from an event handler, for example), but I don't want to do it anyone needs it.

If you just need to disable a tool for an amount of time after a player uses it, using os.time() works just as well. This is the way Buildism and most other games handle this type of thing internally--using sleep() adds an extra thread that does nothing.

[lua]lastClickTime = os.time()
function mouseDown()
if os.time() - lastClickTime < 3 then return end --3 seconds
[...]
lastClickTime = os.time()
end[/lua]
Reply
#2
gameConfusedcheduleTask() - What exactly does this signify? I'm on my way to learning Lua to help people in Scripting section ^^
[Image: poptartFINALTINY.gif]
[Image: log.png?t=1302647037]
Reply
#3
I always use sleep.
Reply
#4
(07-08-2011, 06:37 PM)Login Wrote: gameConfusedcheduleTask() - What exactly does this signify? I'm on my way to learning Lua to help people in Scripting section ^^

I explained it here: http://buildism.net/forum/Thread-I-m-hav...4#pid40294
Reply
#5
I always use sleep :3
Reply
#6
I'm not asking if you use it right now, I'm asking if you can do without it. It would solve a lot of problems.
Reply
#7
(07-08-2011, 09:16 PM)Jacob_ Wrote: I'm not asking if you use it right now, I'm asking if you can do without it. It would solve a lot of problems.

I could switch if it makes things easier Tongue
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)