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

Infinite Loop With Break Switch

Started by saikit555, 21 August 2013 - 09:59 AM
saikit555 #1
Posted 21 August 2013 - 11:59 AM
So i want to have my turtle do an infinite loop. so i did… edit startup
Spoiler

while true do
         shell.run("program")
end

how do i make it so that i can hit a key(e.g. ENTER) to break the loop.
MR_nesquick #2
Posted 21 August 2013 - 12:35 PM
you can try os.pullEvent
Spoiler
local timer = os.startTimer(1)

while true do
event = os.pullEvent()
if event == "key" then
  break
elseif event == "timer" then
  shell.run("program")
  timer = os.startTimer(1)
end
end
Not tested….
saikit555 #3
Posted 21 August 2013 - 01:14 PM
you can try os.pullEvent
Spoiler
local timer = os.startTimer(1)

while true do
event = os.pullEvent()
if event == "key" then
  break
elseif event == "timer" then
  shell.run("program")
  timer = os.startTimer(1)
end
end
Not tested….

it works:) thanks:)