Reputation:
I was looking for a way to pause my program to allow the user to read before it closes but the function (os.sleep(timeSeconds)) doesn't exist apparently. Anyone know a workaround?
Upvotes: 1
Views: 665
Reputation: 22421
Better use OS built-in facilities to retain output window instead of introducing artificial delays. What if user runs your program from already opened command window or redirects output to file? You're forcing him to waste time for nothing.
Upvotes: 2
Reputation: 9340
You could make use of os.clock()
and os.time()
. Ex:
function sleep(n)
local t = os.clock()
while os.clock() - t <= n do
-- nothing
end
end
n is in seconds. Feel free to make the os.time()
version.
Upvotes: 2