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

Dependent Turtle moving API

Started by Jajnick, 15 March 2012 - 11:29 PM
Jajnick #1
Posted 16 March 2012 - 12:29 AM
Good day.
I'm sure that somebody invented this first, but I'll show it anyway. Well, I hope that I spared the time someone. The dependent Turtle moving API allows the Turtle to make different moves depending on the side it's facing, for example:
>The API is loaded and the side is set to front
>Turtle is told to move forward
>Turtle moves forward
>Turtle is told to move left
>Turtle turns left, moves forward and the side is set to left
>Turtle is told to move forward
>Turtle turns right, moves forward and the side is set to front
This allows the programmer to use less imagination and lets him/her focus on the code. In addition, the API has built-in function "force forward", which, as you can guess, will end only if Turtle's moving forward was succesful (functions "force up" and "force down" exist too). Currently it may be unsafe and needs some corrections, but I'll do that later. Every moving function uses it. …Now the commands:
f() - Move forward
l() - Move left
r() - Move right
b() - Move back
u() - Move up
d() - Move down

Example program with DTM API
The API
Teraminer #2
Posted 17 April 2012 - 08:32 PM
Move left makes the turtle turn or just go left?
Xemiru #3
Posted 17 May 2012 - 01:45 AM
Move left makes the turtle turn or just go left?
Both.
Teraminer #4
Posted 17 May 2012 - 11:16 AM
delete this post please