Difference between revisions of "Turtle (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(There is 16 slots, want proof? Go into Minecraft with 1.4 yourself.)
Line 34: Line 34:
 
|-
 
|-
 
|[[turtle.select]]( slotNum )
 
|[[turtle.select]]( slotNum )
|The Turtle selects the given Slot (1 is top left, 16 is bottom right)
+
|The Turtle selects the given Slot (1 is top left, 16 (9 in 1.33 and earlier) is bottom right)
 
|
 
|
 
|-
 
|-

Revision as of 16:55, 16 August 2012

The Turtle API is used to work with your Turtles.

Method name Description Min version
turtle.craft() Craft items using ingredients in the nine upper left slots
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 (9 in 1.33 and earlier) 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. 1.4
turtle.attackDown() Attacks under the turtle. 1.4
turtle.attackUp() Attacks over the turtle. 1.4
turtle.digUp() Breaks the Block above
turtle.digDown() Breaks the Block below
turtle.place( [signText] ) Places a Block of the first available slot in front. Engrave [signText] on signs if provided. 1.4
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 currently selected slot
turtle.compareUp() Detects if the block above is the same as the one in the currently selected slot
turtle.compareDown() Detects if the block below is the same as the one in the currently selected 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. 1.4
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 in front of the turtle. If the turtle can't pick up the item, the function yields false. 1.4
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.
1.4
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".
1.4

Trivia: During the 1.4 beta, turtle.getFuelLevel() in softcore(that is now turtleneedsfuel = 0) returned 9000.