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


Messages In This Thread
Does anyone actually need to use sleep() in an event handler? - by Jacob__mybb_import1 - 07-08-2011, 06:26 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)