This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
lord_darkis's profile picture

[Lua][Question]Help with functions

Started by lord_darkis, 06 May 2012 - 01:49 AM
lord_darkis #1
Posted 06 May 2012 - 03:49 AM
I'm trying to have my program wait an amount of time before it proceeds to the next piece of code, but sleep doesn't seem to be working! Any suggestions?

EDIT: opps typed a true instead of a false somewhere my bad. go help someone else.
Luanub #2
Posted 06 May 2012 - 04:05 AM
Yes I would use os.startTimer() and then os.pullEvent()

Small Example

os.startTimer(5) -- start5 second timer
local, event, p1 == os.pullEvent("timer") -- wait for a timer event
if p1 == "timer" then -- check to make sure the timer went off
insert code to continue
end

You can probably do it without the if statement, but its a good double verification.
Edited on 06 May 2012 - 02:05 AM