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

Looping with re-attempting if dropDown fails?

Started by GoldTrousers, 05 February 2013 - 05:06 PM
GoldTrousers #1
Posted 05 February 2013 - 06:06 PM
I have this turtle set-up to pull items from a chest and place them down in a recycler. So far I have:

i=1
while i == do
   if turtle.suck() == true then
	  turtle.dropDown()
   end
end
How would i make it wait for a 'if turtle.dropDown() == true' if it gets 'turtle.dropDown() == false'? sorry if my question is unclear, I'm a newbie. i tried:
 
i=1
while i == 1 do
   if turtle.suck() == true then
	  if turtle.dropDown() == false then
		 i=2
		 while i == 2 do
		    if turtle.dropDown ~= false
			   i=1
		    end
		 end
	  end
   end
end
	 
I assume i went about this completely the wrong way. I would like to know what im doing wrong and what better ways there are for making programs wait. (once again I'm a newbie to programming)
Lyqyd #2
Posted 05 February 2013 - 07:37 PM
Split into new topic. You did not provide a title, so a title was provided for you. Feel free to edit it by using the Full Editor on your post.

You might try:


while true do
  turtle.suck()
  while not turtle.dropDown() do --as long as turtle.dropDown() returns false
    sleep(0.5) --wait a moment before trying again
  end
end