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

Tmove V1.0.1 - Better Turtle Functions

Started by PappleFruit, 26 July 2013 - 12:42 PM
PappleFruit #1
Posted 26 July 2013 - 02:42 PM
Tired of having to do for- and while-loops for every step, the turtle does? Then TMove is perfect for you!


TMove is a Turtle-API, that adds a bunch of nifty functions to let your turtle dig or move multiple times without you having to implement any loops!

Source Code:
http://pastebin.com/esEygZVC

Functions
Spoiler

up(blocks)
Moves the turtle up the amount of blocks set in the brackets

down(blocks)
Moves the turtle down the amount of blocks set in the brackets

forward(blocks)
Moves the turtle forward the amount of blocks set in the brackets

back(blocks)
Moves the turtle back the amount of blocks set in the brackets

left(blocks)
Moves the turtle left the amount of blocks set in the brackets

right(blocks)
Moves the turtle right the amount of blocks set in the brackets

tLeft(rotations)
Turns the turtle the amount of rotations set left

tRight(rotations)
Turns the turtle the amount of rotations set right

digForward(blocks)
Digs the amount of blocks set forward

digLeft(blocks)
Digs the amount of blocks set left

digRight(blocks)
Digs the amount of blocks set right

digUp(blocks)
Digs the amount of blocks set up

digDown(blocks)
Digs the amount of blocks set down

placeTop(blocks)
Moves the turtle the amount of blocks set forward and places a block on top of the turtle each time

placeBottom(blocks)
Moves the turtle the amount of blocks set forward and places a block under the turtle each time

digTop(blocks)
Moves the turtle the amount of blocks set forward and digs the block on top of the turtle each time

digBottom(blocks)
Moves the turtle the amount of blocks set forward and digs the block under the turtle each time

digAround()
Digs every block around the turtle

placeAround()
Places blocks around the turtle

replaceAround()
Replaces every block around the turtle

fillRect(x, y)
Fills a rectangle of blocks under the turtle, going to the right

digRect(x, y)
Digs a rectangle of blocks under the turtle, going to the right



Installation / Usage
Spoiler

To install the TMove API on one of your turtles, type in the following code:

pastebin get esEygZVC tmove

After you did that, you will have to activate it, either in every program on it's own or on startup, so it's always activated. To activate it, put the following line of code at the beginning of your program:

os.loadAPI("tmove")

Now, the API is activated. To use it, just write tmove.functionname(parameters) in your code. Example:

for i = 1, 4 do
  tmove.placeBottom(8)
  turtle.turnRight()
end



To-Do-List
Spoiler

- Adding a turtle navigation system without GPS


Changelog
Spoiler

V1.0.1
- fixed a few smaller bugs
- removed unnecessary code
- fillRect now fills a rectangle with blocks under the turtle instead of in front of it

V1.0
- First release


I hope you like this API and find use for it. Suggestions and bug reports are always appreciated. :)/>
Zudo #2
Posted 26 July 2013 - 04:53 PM
I like the last 5 functions, but I write my own for the others on the occasion I do make a turtle program.
PappleFruit #3
Posted 27 July 2013 - 04:01 AM
I like the last 5 functions, but I write my own for the others on the occasion I do make a turtle program.
Yeah, many people probably do so but I'm always really lazy when it comes to coding, so I always make myself an API for things like that.