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

how to i loop this code

Started by FaggotNr1, 24 December 2012 - 03:47 AM
FaggotNr1 #1
Posted 24 December 2012 - 04:47 AM
i have this code that plant a sapling and take bonemeal to make it big and then getting the tree then return faces the chest den drops all items in slot 2-14 and i want that too loop but i dont know how to do pls help its means alot /MvH FaggotNr1
Code:

turtle.refuel(1)
turtle.select(16)
turtle.place()
turtle.select(15)
turtle.place()
turtle.dig()
turtle.forward()
while turtle.detectUp do
turtle.digUp()
turtle.up()
end
while not turtle.detectDown do
turtle.down()
end
turtle.turnLeft()
turtle.turnLeft()
if itemcount == 64 then
for i=2,14 do
  turtle.select(i)
  turtle.drop(i)
Edited by
Doyle3694 #2
Posted 24 December 2012 - 05:14 AM
I'm assuming you mean it should loop infinite, if so:

while true do
   turtle.refuel(1)
   turtle.select(16)
   turtle.place()
   turtle.select(15)
   turtle.place()
   turtle.dig()
   turtle.forward()
   while turtle.detectUp do
	  turtle.digUp()
	  turtle.up()
   end
   while not turtle.detectDown do
   turtle.down()
   end
   turtle.turnLeft()
   turtle.turnLeft()
   if itemcount == 64 then
	  for i=2,14 do
		 turtle.select(i)
		 turtle.drop(i)
	  end
   end
end 

Though, itemcount isn't for example a variable, and turtle.detectUp() and turtle.detectDown() needs ()
FaggotNr1 #3
Posted 24 December 2012 - 08:20 AM
I'm assuming you mean it should loop infinite, if so:

	while true do
	   turtle.refuel(1)
	   turtle.select(16)
	   turtle.place()
	   turtle.select(15)
	   turtle.place()
	   turtle.dig()
	   turtle.forward()
	   while turtle.detectUp do
		  turtle.digUp()
		  turtle.up()
	   end
	   while not turtle.detectDown do
	   turtle.down()
	   end
	   turtle.turnLeft()
	   turtle.turnLeft()
	   if itemcount == 64 then
		  for i=2,14 do
			 turtle.select(i)
			 turtle.drop(i)
		  end
	   end
	end
	

Though, itemcount isn't for example a variable, and turtle.detectUp() and turtle.detectDown() needs ()

yeah i know i edited the file after, thanks :)/>