I need some help using this os.Time thing - Printable Version +- 2DWorlds Forums (http://2dworlds.buildism.net/forum) +-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4) +--- Forum: Scripting (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=13) +--- Thread: I need some help using this os.Time thing (/showthread.php?tid=7763) |
I need some help using this os.Time thing - Duck - 08-06-2011 I really don't understand how I can use it to replace sleep() How can I do stuff like this with it?! [lua]while sleep(10) do sleep(0.05) script.Parent.Rotation = 0 end [/lua] RE: I need some help using this os.Time thing - Qwertygiy - 08-06-2011 [lua] function waitFor(time) local waittime = os.time() while os.time() - waittime < time do sleep(0.001) end end [/lua] And then whenever you need to wait a bit, instead of sleep(10) use waitFor(10). RE: I need some help using this os.Time thing - Duck - 08-06-2011 Thank you. RE: I need some help using this os.Time thing - Jacob__mybb_import1 - 08-06-2011 Can you guys post the scripts you are using the waitfor() function in? sleep() for long periods doesn't cause problems by itself, but delaying the execution of an event handler does, and that is exactly what you're doing. RE: I need some help using this os.Time thing - Duck - 08-06-2011 Well I'd rather PM them to you than put them on the forums, is that fine? |