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

Loops - Tekkit classic

Started by fairdude29, 04 April 2014 - 04:53 PM
fairdude29 #1
Posted 04 April 2014 - 06:53 PM
So bassically i want to do a loop in computercraft it uses the turtleos 1.3
So.. i want to loop 8 times the same program ("mine") it is very simple but i want to make it more advanced, like execute after 8 times the "mine" is executed i want it so that it will place a torch down!
There is my code,just give me a example i don't request you to code for me,just a example,ok there's my code:
while true do
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.up()
turtle.dig()
turtle.turnLeft()
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
turtle.down()
end
and my torch program is simple..
turtle.up()
turtle.select(3)
turtle.place()
turtle.down()So
basically i want to run my torch after 8 times executed mine program.
Please help faster.
guesswhat123212 #2
Posted 05 April 2014 - 04:29 AM
if you put your mine code in a function and then your torch code in a function you could loop it like this


  for i = 1, 8 do
    minefunction()
  end
  torchfunction()