5 posts
Posted 08 January 2013 - 06:32 AM
hello guys,
this is my first post. i'm microvip here and ingame.
and i treid to make a automatic tree cutter.
but i get all time the
bios:338: [string "tree"]:9: '<eof>' expected
I test my code everytime so i will be sure to get it working but now am i stuck.
int = 0
while turtle.detect() == true do
turtle.dig()
turtle.digUp()
turtle.up()
end
elseif turtle.down() == false then
turtle.forward()
turtle.select(2)
turtle.dropDown()
turtle.select(3)
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.dropDown()
turtle.turnleft()
turtle.turnLeft()
end
return 0;
this part is fully working.
int = 0
while turtle.detect() == true do
turtle.dig()
turtle.digUp()
turtle.up()
end
Thanks for reading.
gr. Microvip
2088 posts
Location
South Africa
Posted 08 January 2013 - 06:47 AM
Welcome to the forums Microvip :)/>
Ok, so firstly, while loops don't support elseif's, only ifs and i'm not sure what you're trying to do with the return 0 part :P/>
int = 0
while true do
if turtle.detect() == true then -- you don't the == true part too
turtle.dig()
turtle.digUp()
turtle.up()
end
elseif turtle.down() == false then
turtle.forward()
turtle.select(2)
turtle.dropDown()
turtle.select(3)
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.dropDown()
turtle.turnleft()
turtle.turnLeft()
end
end
5 posts
Posted 08 January 2013 - 07:32 AM
Thanks for response,
Now i get another error
bios:338: [string "tree"]:9: 'end' expected (to close 'while' at line 2)
2005 posts
Posted 08 January 2013 - 07:33 AM
Um…you still got an extra and in there. I'm having to guess at the intention of this code. The part that is working is pretty clear. What comes next? Go all the way back down, then drop off your logs (in a chest not so conveniently located under the tree?), turn around and drop off something else (in a chest located under your starting position?), turn around again so you're back where you started.
Okay, see, I'm pretty sure that's not what you want to do.
I think that you do want to come down, which is easy enough. Just another while loop:
while turtle.down() do end
And you're back at the ground (presumably where you started?).
Then you can do some other stuff, put stuff in chests or whatever. And if you want the whole process to repeat you can enclose it all in a while true do…end loop.
5 posts
Posted 08 January 2013 - 07:35 AM
I want it come down and place a new sapling(slot 2) and drop the wood (slot 3) in a chest.
but i gonna try your code.
5 posts
Posted 08 January 2013 - 07:41 AM
It work but The turtle goes up and down. and then waiting for a detection.
EDIT: i got him fully working now.
EDIT: It works but what if i want to plant a sapling and put wood in the chest?
int = 0
while true do
if turtle.detect() then
turtle.dig()
turtle.digUp()
turtle.up()
else turtle.down() do end
end
end
Edited on 08 January 2013 - 07:23 AM
2005 posts
Posted 08 January 2013 - 10:48 AM
You plant saplings using the place command, same as you would use for any other block (place also allows use of many items that can be right-clicked, like buckets).
You drop items into an inventory using the drop commands.
I think that you might be better served by compare than detect for moving up, not least because that will enable you to wait for a sapling to grow into a tree (not as much of a problem if you are using bonemeal, but given that certain conditions can cause bonemeal application to fail, compare is still preferable). It will also prevent you from going all the way up past the top of the canopy, which is a waste of fuel.
You probably want to use a loop with two sequential loops inside of it, to handle the variable tasks (going up and down) and followed by a plant/drop sequence.
5 posts
Posted 08 January 2013 - 11:46 AM
Anyway, thanks for the help. i know enough for now.