Turtle (API)

From ComputerCraft Wiki
Revision as of 10:28, 28 July 2012 by Pinkishu (Talk | contribs)

Jump to: navigation, search

The Turtle API is used to work with your Turtles.

Method name Description
turtle.forward() Let the Turtle move forward
turtle.back() Let the Turtle move back
turtle.up() Let the Turtle move up
turtle.down() Let the Turtle move down
turtle.turnLeft() The Turtle turns left
turtle.turnRight() The Turtle turns right
turtle.select( slotNum ) The Turtle selects the given Slot (1 is top left, 16 is bottom right)
turtle.getItemCount( slotNum ) Counts how many items are in the given Slot
turtle.getItemSpace( slotNum ) Counts how many items you need to fill the stack in the given Slot
turtle.dig() Breaks the Block in front
turtle.attack() Attacks in front of the turtle.
turtle.attackDown() Attacks under the turtle.
turtle.attackUp() Attacks over the turtle.
turtle.digUp() Breaks the Block above
turtle.digDown() Breaks the Block below
turtle.place() Places a Block of the first available slot in front
turtle.placeUp() Places a Block of the first available slot above
turtle.placeDown() Places a Block of the first available slot below
turtle.detect() Detects if there is a Block in front
turtle.detectUp() Detects if there is a Block above
turtle.detectDown() Detects if there is a Block below
turtle.compare() Detects if the block in front is the same as the one in the first available slot
turtle.compareUp() Detects if the block above is the same as the one in the first available slot
turtle.compareDown() Detects if the block below is the same as the one in the first available slot
turtle.compareTo( [slot] ) Compare the current selected slot and the given slot to see if the items are the same, yields true if they are the same, and false if not.
turtle.drop( [count] ) Drops all items in the selected slot, or if [count] is specified, drops that many items. If there is a inventory on the side it will try to place into the inventory, returning false if the inventory is full.
turtle.suck() Picks up an item from the ground or an inventory at the side, if the turtle can't pickup the item the function yields false.
turtle.refuel() If the current selected slot contains a fuel item, it will consume it to give the turtle the ability to move. Added in 1.4 and is only needed in hardcore turtle mode. If the current slot doesn't contain a fuel item, it yields false.
turtle.getFuelLevel() Returns the current fuel level of the turtle, this is the number of blocks the turtle can move. In softcore turtle mode it yields "unlimited".

Trivia: In 1.4 turtle.getFuelLevel() in softcore returned 9000