Disabling sleep() in events would solve a whole lot of issues and confusing things about scripting (having to use game
cheduleTask() 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]
![Confused Confused](http://2dworlds.buildism.net/forum/images/smilies/confused.png)
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]