3 posts
Posted 05 January 2013 - 09:58 AM
I have looked into loops and tried using the While <condition> do and it did not work here is my code.
while turtle.detectFront=true do
turtle.dig()
end
while turtle.detectFront=false do
turtle.forward()
end
1111 posts
Location
Portland OR
Posted 05 January 2013 - 10:02 AM
turtle.detectFront is actually just turtle.detect() and it is a function call it needs () at the end and when you do comparisions its == to assign a value its = but to check bools you dont need the == just do this
while turtle.detect() do --while its true
turtle.dig()
end
while not turtle.detect() do --while its false
turtle.forward()
end
3 posts
Posted 05 January 2013 - 10:11 AM
i got it mostly working now but when ever it mines a block it just stops and doesn't loop again
New Code:
while turtle.detect() do
turtle.dig()
end
while not turtle.detect() do
turtle.forward()
end
2005 posts
Posted 05 January 2013 - 10:18 AM
Of course, this is more useful if you are going to do things more than once, so:
while turtle.detect() do --while its true
turtle.dig()
turtle.digUp()
turtle.forward()
end
This way we keep going forward as long as we find things to dig, and stop when we hit an empty space.
umm…be careful with this, it will dig itself into a wall and you might not be able to find it for a while.
Okay, now you should be able to follow it easily enough.
Edited on 05 January 2013 - 09:19 AM
3 posts
Posted 05 January 2013 - 10:26 AM
Thank you for the help.
25 posts
Location
A flatland world with 100's of computers and a village that was covered with lava with a parkour course about it; Minecraftia.
Posted 05 January 2013 - 10:39 AM
Maybe try learning a bit more on lua coding before you start trying to make turtle programs? Start with something simple. Learn how lua actually works a bit before moving onto CC :)/>.
2005 posts
Posted 05 January 2013 - 10:41 AM
Naw. I mean, you can do a lot of fun stuff in CC without knowing any programming at all. It's just that if you want to start making your own programs rather than relying on the default programs and whatever you can dredge out of the Programs/Turtle Programs forums, then you need to start learning Lua.