lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I think Lua doesn't have os.sleep() (the name usually given) because it's not in the C standard. There's a way around it in plain Lua, assuming os.time() uses seconds as its unit (which is the case on at least Windows and Linux):

function wait(seconds)
  local start = os.time()
  repeat until os.time() > start + seconds
end

for i=1,10 do
  print(i)
  wait(7)
end

Off-topic: The keywords in your code are capitalized though keywords in Lua are case sensitive. Just so you know.

 - Peter

Rolf wrote:
Sorry for a newbie question. I am not a programmer, but I have just started to use LUA in an application that supports LUA scripts.

I need a pause or wait command inside my script;

For example:

For i=1,10 do

Print(i)

Wait(7)

End

In this script I would print “i” every 7 sec. Is there such a simple wait command included in LUA?

Surprised if there is not…?

I searched the LUA archive, but only found discussions about coroutine.yield(). However, I do not understand how to use this or if they can even be called in the application that I am using (EccoExt for Ecco Pro. See the Tutorials here http://eccowiki.com/)

TIA!!