require "os" -- get start time, and just keep subtracting it from the current time -- until it is greater than the time specified. Also note that 'os.clock()' -- works in seconds not 'ticks' or milliseconds or w/e. This function respects -- that, and thus time must be specified 'in seconds' (e.g. one second would be -- '1', not '1000', half a second would be '.5' not '500', and so forth) function Sleep(length) local start = os.clock() while os.clock() - start < length do end end -- just an implementation, ignore if you don't care print("Ignition in...") for i = 0,9 do print(10-i .. "...") Sleep(1) end print("Blast off!")
[LUA]Sleep Function
Page 1 of 10 Replies - 1287 Views - Last Post: 19 May 2010 - 03:49 PM
#1
[LUA]Sleep Function
Posted 19 May 2010 - 03:49 PM
Description: Should work fine. Report errors if you have any :DAn easy to use Sleep function that can really come in handy (especially debugging) :)
Page 1 of 1