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

Auto farming Turtle help?

Started by Riggs Eclipse, 22 October 2014 - 04:59 AM
Riggs Eclipse #1
Posted 22 October 2014 - 06:59 AM
So past hour or so I've been trying to get my farming turtle to automatically harvest and replant crops. Now I'm am totally new at this, like I have no experience with programming anything at all but really want to learn this kind of thing. After looking around some I've figured out how to get it to harvest and replant the crops, moving one block forward every time it does but it does so in one direction infinitely. How do I tell it to stop after a certain amount of blocks? Basically I need it to loop until it gets to a certain point then stopping.

while true do
turtle.forward(1)
turtle.digDown(1)
turtle.placeDown(1)
end

That's all I have and really all I know how to do sooo… Anyone can help out the new guy I'd appreciate it! And if I'm formatting this wrong I sincerely apologize I just got my account like two minutes ago hehe
com_kieffer #2
Posted 22 October 2014 - 11:16 AM

local max_moves = 10
for i = 1, max_moves do
	turtle.forward(1)
	turtle.digDown(1)
	turtle.placeDown(1)
end

Just change the value of max_moves to the the number of times you want to move forwards.
Edited on 22 October 2014 - 09:17 AM
KingofGamesYami #3
Posted 22 October 2014 - 02:09 PM
FYI: turtle.forward, turtle.digDown, and turtle.placeDown don't accept arguments. Giving them a '1' is irrelevant to what they are going to do.