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

Sugar Cane Harvesting Turtles

Started by reptar, 28 June 2012 - 05:18 PM
reptar #1
Posted 28 June 2012 - 07:18 PM
So I've been trying to get this to work for most of the day. I want to create a mining turtle program that automatically harvests my sugarcane. The sugar cane farm is built in strips that are 2 blocks wide and 30 blocks long, with a strip of water in the middle of these strips of sugar cane. I can get it to harvest strips fine, but I would like to add a function to return the turtle to the corner of the farm, where it would dump its harvest, and wait 520 seconds before starting up again. If anyone could help i would be very grateful.
reptar #2
Posted 28 June 2012 - 07:40 PM
bamp i need halp
kazagistar #3
Posted 28 June 2012 - 07:44 PM
I mean, you know how to make the turtle move, so you can make it move back, right? To drop it's contents, you just need to use turtle.select() and turtle.drop(). To wait, you use sleep(). The documentation for all these functions is on the wiki.
Okyloky9 #4
Posted 30 June 2012 - 11:39 AM
x= sugarcane
o=water
[]=turtle
O=drop off hole

this code works for this setup only, tweeks can be made.

xox
xox
xox
xox
xox
O[] (the turtle is 1 block off the ground.)


turtle.select(1)
while turtle.detect() do
turtle.dig()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.drop()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
term.clear()
term.setCursorPos(1,1)
sleep(520)

code is long, prob can be shortened, but here it is.
Okyloky9 #5
Posted 30 June 2012 - 11:43 AM
xox
xox
xox
xox
|—>xox
|————————————————————————————————————————————————|
O[] (the turtle is 1 block off the ground. It wont post correctly, but the turtle is supposed to be at the first sugarcane |
reptar #6
Posted 01 July 2012 - 02:16 AM
hey thanks alot everyone, but i think i got it

heres the code i came up with


while true do
for a=1,10 do
for e=1,31 do
turtle.forward()
turtle.dig()
end
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
for i=1,31 do
turtle.forward()
turtle.dig()
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end
turtle.turnRight()
for o=1,20 do
turtle.forward()
end
turtle.turnLeft()
for u=1,6 do
turtle.select((u))
turtle.drop()
end
end