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

Turtle Oak Tree Farm Help

Started by Adjgamer, 03 January 2013 - 01:42 AM
Adjgamer #1
Posted 03 January 2013 - 02:42 AM
Kayso, I am writing a "simple" oak tree farm and it can't figure out how to write the actual tree farming part. Here is the code:

function refuel()
  turtle.select(1)
  turtle.refuel(1)
  print(turtle.getFuelLevel())
end
function getfuel()
  if turtle.getFuelLevel > 20 then
    refuel()
  end
end
function grow()
  turtle.select(2)
  turtle.place()
  turtle.select(3)
  turtle.place()
  turtle.dig()
  turtle.forward()
end

function farm()
--this is where i am having issues i want the turtle to keep
--digging up until turtle.detectUp == false
--but i don't know how to write it :/
function all()
  getfuel()
  grow()
  farm()
end
all()
zekesonxx #2
Posted 03 January 2013 - 03:18 AM

while not turtle.detectUp() do
  turtle.select(17)
  turtle.digLeft()
  turtle.win(positive)
end
theoriginalbit #3
Posted 03 January 2013 - 03:20 AM
To get it to dig up until there is nothing else above it use


while turtle.detectUp() do
  turtle.digUp()
  if not turtle.up() then
     -- most likely out of fuel
  end
  sleep(0.01) -- let it yield
end
theoriginalbit #4
Posted 03 January 2013 - 03:22 AM

while not turtle.detectUp() do
  turtle.select(17)
  turtle.digLeft()
  turtle.win(positive)
end
Dude if your not going to post anything helpful don't bother posting at all!!!
zekesonxx #5
Posted 03 January 2013 - 03:31 AM

while not turtle.detectUp() do
  turtle.select(17)
  turtle.digLeft()
  turtle.win(positive)
end
Dude if your not going to post anything helpful don't bother posting at all!!!

Oops, I put a 'not' in there didn't I? If you take the 'not' out and put in actual code in the middle it should work fine.
theoriginalbit #6
Posted 03 January 2013 - 03:36 AM

while not turtle.detectUp() do
  turtle.select(17)
  turtle.digLeft()
  turtle.win(positive)
end
Dude if your not going to post anything helpful don't bother posting at all!!!

Oops, I put a 'not' in there didn't I? If you take the 'not' out and put in actual code in the middle it should work fine.

No it won't work at all. Lets pull it apart line by line
1: you have a not, they don't want it to run when it's not there
2: firstly why are you selecting a slot? Not needed. Secondly slot 17 doesn't exist, the code would error at this point
3: turtle.digLeft doesn't exist, and if it did exist it definitely doesn't help it dig UP!
4: I don't even think that line deserves saying anything, it is pure stupid.

And if you are giving the person pseudo/dummy code, maybe don't do it in a way that they think is real and will try it, either do pseudo in plain English sentences or give them the real lines.