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

Tree Farm Problem

Started by Priamos7, 12 December 2012 - 11:35 PM
Priamos7 #1
Posted 13 December 2012 - 12:35 AM
local NS = 0
local OW = 0
local height = 0
local slot = 1

function CheckItems()
if turtle.getItemCount(6) == 64 then
BTB()
else
CheckTrees()
end
end

function BTB()
turtle.turnLeft()
repeat
turtle.forward()
OW = OW - 1
until OW == 0
turtle.turnLeft()
repeat
turtle.forward()
NS = NS - 1
until NS == 0
turtle.down()
repeat
local slot = 1
turtle.select(slot)
sleep(0.3)
turtle.drop(turtle.getItemCount(slot))
slot = slot + 1
until slot == 8
turtle.turnLeft()
turtle.turnLeft()
turtle.select(1)
if turtle.getItemSpace(9) == 64 then
print("Need Saplings")
else
GetUp()
end
end

function GetUp()
turtle.up()
height = height + 1
turtle.forward()
NS = NS + 1
turtle.turnRight()
turtle.forward()
OW = OW + 1
turtle.turnLeft()
sleep(1)
CheckTrees()
end

function CheckTrees()
if turtle.getItemSpace(9) == 64 then
BTB()
elseif (OW == 13 and NS == 13) then
BTB()
elseif OW == 13 then
turtle.turnLeft()
repeat
turtle.forward()
OW = OW - 1
until OW == 0
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.forward()
NS = NS + 3
turtle.turnRight()
turtle.forward()
OW = OW + 1
turtle.turnLeft()
Chop()
else
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.forward()
OW = OW + 3
turtle.turnLeft()
sleep(0.5)
Chop()
end
end

function Chop()
if turtle.detect() then
turtle.down()
height = height - 1
while turtle.detect() do
turtle.dig()
turtle.digUp()
turtle.up()
height = height + 1
end
repeat
turtle.down()
turtle.digDown()
height = height - 1
until height == 0
if turtle.getItemSpace(9) == 64 then
BTB()
else
turtle.select(9)
end
sleep(0.3)
turtle.place()
turtle.up()
height = height + 1
CheckItems()
else
CheckTrees()
end
end

GetUp()
_________________________________

Hi guys, i have been playing tekkit for a while now, but i got pretty bored today in lecture so i started to use ComputerCraft. I have to say I really love the turtles. Nevertheless i encountered a Problem. My Item Drop Loop is not working as desired and my turtle does not detect the first tree it encounters (when the CheckTrees function runs the first time)
I appreciate your help and Thanks in advance
Lyqyd #2
Posted 13 December 2012 - 03:43 AM
Move local slot = 1 to just before the repeat so it doesn't just loop on that slot.
Priamos7 #3
Posted 13 December 2012 - 05:32 AM
damn that was stupid shouldnt write when im too tired