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

Turtle Track Driving Thing

Started by Mitchfizz05, 30 September 2012 - 10:17 AM
Mitchfizz05 #1
Posted 30 September 2012 - 12:17 PM
Ok, I've researched a little and discovered how to make some basic programs.
Now this is the very first thing I've EVER done in computercraft, well… except for just making a computer print "Mitchfizz05's Computer" when I turn it on.
This turtle program will make a turtle drive, and whenever their is a block in front of it, it will turn right.
If the turtle isn't on a block, it will stop there.
Oh, and if anyone knows how to make a turtle know what block is under it or in front of it, that would help me alot. :)/>/>


print("Will begin driving in 3 seconds!")
sleep(1)
print("2 seconds!")
sleep(1)
print("1 second!")
sleep(1)
print("Begun driving!")
while true do
if turtle.detect() then
turtle.turnRight()
end
turtle.forward()
if turtle.detectDown() then
else
break
end
end
I know it is a boring program, well not boring (quite fun actually) but simple. I thought I'd upload it anyway.
For me, it's a big achievement.

Also, if you want the startup code to go on a floppy disk, here it is:

print("Copying files to turtle...")
fs.copy("disk/drive","drive")
print("Copy complete!")
print("Running program...")
shell.run("drive")
And once again, if anyone knows how to make a turtle detect WHAT block is in front of it or below it, please tell me. :(/>/>
auser #2
Posted 01 October 2012 - 05:43 AM
try turtle.compare() and its cousins compareUp() compareDown()
it compares what is in your slection with what is infront of you
rail/tracks may be harder to follow
also read some of the features of the api's there may be a lot that is already written for you
: )