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

turtle Cocoa farm not running

Started by Riv991, 15 June 2013 - 08:50 AM
Riv991 #1
Posted 15 June 2013 - 10:50 AM
When I use just the farm function it works perfectly but when I add either the Bonemeal or Drop function it will not run, I assume it's a problem on my part but I have no idea how to fix it as it isn't throwing up an error messages. Thanks for your help.


-- Variables
turtle.select(1)
local tArgs = { ... }
local togo = tonumber(tArgs[1])
togo = togo or 64
print("I'll DOOOOOO IT!!!!!")


-- Farming
	 function Farm()
		 for i = 1, togo do
	  turtle.place()
	  turtle.select(2)
	  turtle.place()
	  turtle.select(1)
	  turtle.dig()
	 end


-- Drop In Chest
function Drop()
	 turtle.select(3)
	 turtle.turnRight()
	 turtle.turnRight()
	 turtle.drop()
	 turtle.turnRight()
	 turtle.turnRight()
   end
  -- Refuel Bonemeal
	function bonemeal()
	M = turtle.getItemCount(2)
	if M < 1 then
	  turtle.suck(up)
	 else
	   turtle.detect()
	 end	
  Farm()
	bonemeal()
	  Drop()
	end
end
Lyqyd #2
Posted 15 June 2013 - 08:31 PM
Split into new topic.
ETHANATOR360 #3
Posted 15 June 2013 - 08:37 PM
what error does it give you?
edit: ah never mind
Bomb Bloke #4
Posted 15 June 2013 - 08:40 PM
It's "turtle.suckUp()", not "turtle.suck(up)".

And change the end from:

.
.
.
           turtle.detect()
         end    
  Farm()
        bonemeal()
          Drop()
        end
end

… to something like:

.
.
.
           turtle.detect()
         end    
  end

    while true do
        Farm()
        bonemeal()
          Drop()
end

… only with better indentation. You're also missing an "end" at the bottom of the "farm" function - remember the "for" loop needs one too.

Even then, it's possible that farming may result in the use of the last bit of your bonemeal, in which case the crop will be harvested into slot 2. One way to deal with this is to keep a bit of wheat in the very last slot so you can make use of turtle.compareTo() to ensure the correct item type goes into the output chest.

I guess you're planning on later putting a chest under the turtle to replenish seed supplies.
ETHANATOR360 #5
Posted 15 June 2013 - 09:23 PM
i copied the code it doenst give an error
Bomb Bloke #6
Posted 15 June 2013 - 11:07 PM
Yes, that's 'cause he rigged it in such a way that his functions never got called.
Riv991 #7
Posted 16 June 2013 - 05:00 AM
It's "turtle.suckUp()", not "turtle.suck(up)".

And change the end from:

.
.
.
		   turtle.detect()
		 end	
  Farm()
		bonemeal()
		  Drop()
		end
end

… to something like:

.
.
.
		   turtle.detect()
		 end	
  end

	while true do
		Farm()
		bonemeal()
		  Drop()
end

… only with better indentation. You're also missing an "end" at the bottom of the "farm" function - remember the "for" loop needs one too.

Even then, it's possible that farming may result in the use of the last bit of your bonemeal, in which case the crop will be harvested into slot 2. One way to deal with this is to keep a bit of wheat in the very last slot so you can make use of turtle.compareTo() to ensure the correct item type goes into the output chest.

I guess you're planning on later putting a chest under the turtle to replenish seed supplies.

I did the changes you suggest and there's one problem with it, it constantly loops and the number I enter just changes how many it farms before dropping it in the chest. Is there a way to call the functions and to fix this?
Bomb Bloke #8
Posted 16 June 2013 - 05:47 AM
Oh, sorry, I assumed you wouldn't want it to stop. Silly of me, what with that arguement-handling code and all.

The edits I suggested DO result in the functions being called, but they end up being called over and over forever. Get rid of the "while true do" line and the final "end" statement and the loop's gone.

If that still isn't what you're expecting, please be specific about what you are expecting.