Difference between revisions of "Turtle (API)"
From ComputerCraft Wiki
(Fixed mess in list, added fuel value link) |
(added dropUp and dropDown, link to drop page, will edit that to include notes on variants next) |
||
Line 111: | Line 111: | ||
|[[turtle.drop]]( [count] ) | |[[turtle.drop]]( [count] ) | ||
|Drops all items in the selected slot, or if [count] is specified, drops that many items.<br />If there is a inventory on the side it will try to place into the inventory, returning false if the inventory is full. | |Drops all items in the selected slot, or if [count] is specified, drops that many items.<br />If there is a inventory on the side it will try to place into the inventory, returning false if the inventory is full. | ||
+ | | | ||
+ | |- | ||
+ | |[[turtle.drop|turtle.dropDown]]( [count] ) | ||
+ | |Drops all items in the selected slot, or if [count] is specified, drops that many items.<br />If there is a inventory on the side it will try to place into the inventory, returning false if the inventory is full. If above a furnace, will place item in the top slot. | ||
+ | | | ||
+ | |- | ||
+ | |[[turtle.drop|turtle.dropUp]]( [count] ) | ||
+ | |Drops all items in the selected slot, or if [count] is specified, drops that many items.<br />If there is a inventory on the side it will try to place into the inventory, returning false if the inventory is full. If below a furnace, will place item in the bottom slot. | ||
| | | | ||
|- | |- |
Revision as of 05:15, 19 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.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.dig() | Breaks the Block in front | |
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.dropDown( [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. If above a furnace, will place item in the top slot. |
|
turtle.dropUp( [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. If below a furnace, will place item in the bottom slot. |
|
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. Fuel values for different items can be found at Turtle.refuel#Fuel_Values. |
1.4 |
turtle.getFuelLevel() | Returns the current fuel level of the turtle, this is the number of blocks the turtle can move. If turtleNeedFuel = 0 then it yields "unlimited". |
1.4 |
Trivia: During the 1.4 beta, turtle.getFuelLevel() in softcore(that is now turtleneedsfuel = 0) returned 9000.