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

Sleeping turtles help

Started by Mendoza, 21 January 2014 - 09:49 AM
Mendoza #1
Posted 21 January 2014 - 10:49 AM
Hello, I need help with this: The turtle will run a code, in a repeat loop, and in the end of the loop, the turtle will wait until the sleep() finishes or when a redstone signal is received. Then the loop begins another time

The loop is infinite

An example: My turtle will harvest an area each hour or when the turtle receives a redstone signal



Thanks in advance
Lyqyd #2
Posted 21 January 2014 - 12:16 PM
Please post the code you have so far.
H4X0RZ #3
Posted 21 January 2014 - 05:25 PM

while true do
  --your code here
  parallel.waitForAny(function() sleep(time) end,  function() os.pullEvent('redstone') end)
end
Mendoza #4
Posted 22 January 2014 - 09:21 AM
Thanks