19 posts
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()
264 posts
Location
Where you aren't
Posted 03 January 2013 - 03:18 AM
while not turtle.detectUp() do
turtle.select(17)
turtle.digLeft()
turtle.win(positive)
end
7508 posts
Location
Australia
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
7508 posts
Location
Australia
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!!!
264 posts
Location
Where you aren't
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.
7508 posts
Location
Australia
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.