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

How do I make a repeat programme.

Started by blackoutx98, 04 July 2012 - 05:28 PM
blackoutx98 #1
Posted 04 July 2012 - 07:28 PM
Basically what I want to do, is make a redstone circuit which would go on and off, but I don't want to constantly write-
redstone.setOutput("left", true)
sleep(1)
redstone.setOutput("left", false)

Also, I want to make it so I can tell it when to switch off, can someone help me?

I'm a newbie programmer so I don't have a clue :P/>/>
MysticT #2
Posted 04 July 2012 - 07:56 PM
You need to use some loop. To create an infinite loop, use:

while true do
  -- code
end
To repeat something a certain amount of times, is better to use a for loop:

for var = start, end[, increment] do
  -- code
end
You can read more about loops on the lua manual.
blackoutx98 #3
Posted 04 July 2012 - 07:58 PM
Okay, thanks :P/>/>, I'm not so great at understanding programming language xD, I will try though :)/>/>