Difference between revisions of "Turtle (API)"
From ComputerCraft Wiki
m (Bye bye redirects.) |
Smiley43210 (Talk | contribs) m (Corrected types: bool -> boolean) |
||
Line 23: | Line 23: | ||
! Min version | ! Min version | ||
|-{{row-lightgreen}} | |-{{row-lightgreen}} | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.craft]]( quantity ) | |[[turtle.craft]]( quantity ) | ||
|Craft items using ingredients anywhere in the Turtle's inventory and place results in the active slot. If a quantity is specified, it will craft only up to that many items, otherwise, it will craft as many of the items as possible. | |Craft items using ingredients anywhere in the Turtle's inventory and place results in the active slot. If a quantity is specified, it will craft only up to that many items, otherwise, it will craft as many of the items as possible. | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.forward]]() | |[[turtle.forward]]() | ||
|Let the Turtle move forward | |Let the Turtle move forward | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.back]]() | |[[turtle.back]]() | ||
|Let the Turtle move back | |Let the Turtle move back | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.up]]() | |[[turtle.up]]() | ||
|Let the Turtle move up | |Let the Turtle move up | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.down]]() | |[[turtle.down]]() | ||
|Let the Turtle move down | |Let the Turtle move down | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.turnLeft]]() | |[[turtle.turnLeft]]() | ||
|Let the Turtle turn left | |Let the Turtle turn left | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.turnRight]]() | |[[turtle.turnRight]]() | ||
|Let the Turtle turn right | |Let the Turtle turn right | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.select]](slotNum) | |[[turtle.select]](slotNum) | ||
|The Turtle selects the given Slot (1 is top left, 16 (9 in 1.33 and earlier) is bottom right) | |The Turtle selects the given Slot (1 is top left, 16 (9 in 1.33 and earlier) is bottom right) | ||
Line 73: | Line 73: | ||
| | | | ||
|-{{row-lightred}} | |-{{row-lightred}} | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.attack]]() | |[[turtle.attack]]() | ||
|Attacks in front of the turtle. | |Attacks in front of the turtle. | ||
| 1.4 | | 1.4 | ||
|-{{row-lightred}} | |-{{row-lightred}} | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.attackUp]]() | |[[turtle.attackUp]]() | ||
|Attacks over the turtle. | |Attacks over the turtle. | ||
| 1.4 | | 1.4 | ||
|-{{row-lightred}} | |-{{row-lightred}} | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.attackDown]]() | |[[turtle.attackDown]]() | ||
|Attacks under the turtle. | |Attacks under the turtle. | ||
| 1.4 | | 1.4 | ||
|-{{row-lightyellow}} | |-{{row-lightyellow}} | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.dig]]() | |[[turtle.dig]]() | ||
|Breaks the Block in front. With hoe: tills the dirt in front of it. | |Breaks the Block in front. With hoe: tills the dirt in front of it. | ||
| | | | ||
|-{{row-lightyellow}} | |-{{row-lightyellow}} | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.digUp]]() | |[[turtle.digUp]]() | ||
|Breaks the Block above. With hoe: tills the dirt above it. | |Breaks the Block above. With hoe: tills the dirt above it. | ||
| | | | ||
|-{{row-lightyellow}} | |-{{row-lightyellow}} | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.digDown]]() | |[[turtle.digDown]]() | ||
|Breaks the Block below. With hoe: tills the dirt below it. | |Breaks the Block below. With hoe: tills the dirt below it. | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.place]](signText) | |[[turtle.place]](signText) | ||
|Places a Block of the selected slot in front. Engrave signText on signs if provided. | |Places a Block of the selected slot in front. Engrave signText on signs if provided. | ||
| 1.4 | | 1.4 | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.placeUp]]() | |[[turtle.placeUp]]() | ||
|Places a Block of the selected slot above | |Places a Block of the selected slot above | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.placeDown]]() | |[[turtle.placeDown]]() | ||
|Places a Block of the selected slot below | |Places a Block of the selected slot below | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} result |
|[[turtle.detect]]() | |[[turtle.detect]]() | ||
|Detects if there is a Block in front. Does not detect mobs. | |Detects if there is a Block in front. Does not detect mobs. | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} result |
|[[turtle.detectUp]]() | |[[turtle.detectUp]]() | ||
|Detects if there is a Block above | |Detects if there is a Block above | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} result |
|[[turtle.detectDown]]() | |[[turtle.detectDown]]() | ||
|Detects if there is a Block below | |Detects if there is a Block below | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} result |
|[[turtle.compare]]() | |[[turtle.compare]]() | ||
|Detects if the block in front is the same as the one in the currently selected slot | |Detects if the block in front is the same as the one in the currently selected slot | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} result |
|[[turtle.compareUp]]() | |[[turtle.compareUp]]() | ||
|Detects if the block above is the same as the one in the currently selected slot | |Detects if the block above is the same as the one in the currently selected slot | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} result |
|[[turtle.compareDown]]() | |[[turtle.compareDown]]() | ||
|Detects if the block below is the same as the one in the currently selected slot | |Detects if the block below is the same as the one in the currently selected slot | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} result |
|[[turtle.compareTo]](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. | |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 | | 1.4 | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.drop]](count) | |[[turtle.drop]](count) | ||
|Drops all items in the selected slot, or if count is specified, drops that many items.<br />[>= 1.4 only:] If there is a inventory on the side (i.e in front of the turtle) 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 />[>= 1.4 only:] If there is a inventory on the side (i.e in front of the turtle) it will try to place into the inventory, returning false if the inventory is full. | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.drop|turtle.dropUp]](count) | |[[turtle.drop|turtle.dropUp]](count) | ||
|Drops all items in the selected slot, or if count is specified, drops that many items.<br />[>= 1.4 only:] If there is a inventory on the side (i.e above the turtle) 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. | |Drops all items in the selected slot, or if count is specified, drops that many items.<br />[>= 1.4 only:] If there is a inventory on the side (i.e above the turtle) 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. | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.drop|turtle.dropDown]](count) | |[[turtle.drop|turtle.dropDown]](count) | ||
|Drops all items in the selected slot, or if count is specified, drops that many items.<br />[>= 1.4 only:] If there is a inventory on the side (i.e below the turtle) 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. | |Drops all items in the selected slot, or if count is specified, drops that many items.<br />[>= 1.4 only:] If there is a inventory on the side (i.e below the turtle) 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. | ||
| | | | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.suck]]() | |[[turtle.suck]]() | ||
|Picks up an item stack of any number, from the ground or an inventory in front of the turtle. If the turtle can't pick up the item, the function yields false. | |Picks up an item stack of any number, 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 | | 1.4 | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.suck|turtle.suckUp]]() | |[[turtle.suck|turtle.suckUp]]() | ||
|Picks up an item stack of any number, from the ground or an inventory above the turtle. If the turtle can't pick up the item, the function yields false. | |Picks up an item stack of any number, from the ground or an inventory above the turtle. If the turtle can't pick up the item, the function yields false. | ||
| 1.4 | | 1.4 | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.suck|turtle.suckDown]]() | |[[turtle.suck|turtle.suckDown]]() | ||
|Picks up an item stack of any number, from the ground or an inventory below the turtle. If the turtle can't pick up the item, the function yields false. | |Picks up an item stack of any number, from the ground or an inventory below the turtle. If the turtle can't pick up the item, the function yields false. | ||
| 1.4 | | 1.4 | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.refuel]](quantity) | |[[turtle.refuel]](quantity) | ||
|If the current selected slot contains a fuel item, it will consume it to give the turtle the ability to move.<br />Added in 1.4 and is only needed in needfuel 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]]. If a quantity is specified, it will refuel only up to that many items, otherwise, it will consume all the items in the slot. | |If the current selected slot contains a fuel item, it will consume it to give the turtle the ability to move.<br />Added in 1.4 and is only needed in needfuel 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]]. If a quantity is specified, it will refuel only up to that many items, otherwise, it will consume all the items in the slot. | ||
Line 193: | Line 193: | ||
| 1.4 | | 1.4 | ||
|- | |- | ||
− | |{{type| | + | |{{type|boolean}} success |
|[[turtle.transferTo]](slot, quantity) | |[[turtle.transferTo]](slot, quantity) | ||
|Transfers items from the selected slot to the specified slot in the [quantity] inputted. | |Transfers items from the selected slot to the specified slot in the [quantity] inputted. |
Revision as of 15:16, 2 May 2013
The Turtle API is used to work with your Turtles.
Key
Color | Turtles that can perform this |
---|---|
White | All |
Green | Crafty |
Yellow | Mining, Felling, Digging, Farming |
Red | Any tool |
API
Return | Method name | Description | Min version |
---|---|---|---|
boolean success | turtle.craft( quantity ) | Craft items using ingredients anywhere in the Turtle's inventory and place results in the active slot. If a quantity is specified, it will craft only up to that many items, otherwise, it will craft as many of the items as possible. | |
boolean success | turtle.forward() | Let the Turtle move forward | |
boolean success | turtle.back() | Let the Turtle move back | |
boolean success | turtle.up() | Let the Turtle move up | |
boolean success | turtle.down() | Let the Turtle move down | |
boolean success | turtle.turnLeft() | Let the Turtle turn left | |
boolean success | turtle.turnRight() | Let the Turtle turn right | |
boolean success | turtle.select(slotNum) | The Turtle selects the given Slot (1 is top left, 16 (9 in 1.33 and earlier) is bottom right) | |
int result | turtle.getItemCount(slotNum) | Counts how many items are in the given Slot | |
int result | turtle.getItemSpace(slotNum) | Counts how many remaining items you need to fill the stack in the given Slot | |
boolean success | turtle.attack() | Attacks in front of the turtle. | 1.4 |
boolean success | turtle.attackUp() | Attacks over the turtle. | 1.4 |
boolean success | turtle.attackDown() | Attacks under the turtle. | 1.4 |
boolean success | turtle.dig() | Breaks the Block in front. With hoe: tills the dirt in front of it. | |
boolean success | turtle.digUp() | Breaks the Block above. With hoe: tills the dirt above it. | |
boolean success | turtle.digDown() | Breaks the Block below. With hoe: tills the dirt below it. | |
boolean success | turtle.place(signText) | Places a Block of the selected slot in front. Engrave signText on signs if provided. | 1.4 |
boolean success | turtle.placeUp() | Places a Block of the selected slot above | |
boolean success | turtle.placeDown() | Places a Block of the selected slot below | |
boolean result | turtle.detect() | Detects if there is a Block in front. Does not detect mobs. | |
boolean result | turtle.detectUp() | Detects if there is a Block above | |
boolean result | turtle.detectDown() | Detects if there is a Block below | |
boolean result | turtle.compare() | Detects if the block in front is the same as the one in the currently selected slot | |
boolean result | turtle.compareUp() | Detects if the block above is the same as the one in the currently selected slot | |
boolean result | turtle.compareDown() | Detects if the block below is the same as the one in the currently selected slot | |
boolean result | 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 |
boolean success | turtle.drop(count) | Drops all items in the selected slot, or if count is specified, drops that many items. [>= 1.4 only:] If there is a inventory on the side (i.e in front of the turtle) it will try to place into the inventory, returning false if the inventory is full. |
|
boolean success | turtle.dropUp(count) | Drops all items in the selected slot, or if count is specified, drops that many items. [>= 1.4 only:] If there is a inventory on the side (i.e above the turtle) 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. |
|
boolean success | turtle.dropDown(count) | Drops all items in the selected slot, or if count is specified, drops that many items. [>= 1.4 only:] If there is a inventory on the side (i.e below the turtle) 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. |
|
boolean success | turtle.suck() | Picks up an item stack of any number, 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 |
boolean success | turtle.suckUp() | Picks up an item stack of any number, from the ground or an inventory above the turtle. If the turtle can't pick up the item, the function yields false. | 1.4 |
boolean success | turtle.suckDown() | Picks up an item stack of any number, from the ground or an inventory below the turtle. If the turtle can't pick up the item, the function yields false. | 1.4 |
boolean success | turtle.refuel(quantity) | 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 needfuel 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. If a quantity is specified, it will refuel only up to that many items, otherwise, it will consume all the items in the slot. |
1.4 |
int fuel | 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 |
boolean success | turtle.transferTo(slot, quantity) | Transfers items from the selected slot to the specified slot in the [quantity] inputted. | 1.45 |
Trivia: During the 1.4 beta, turtle.getFuelLevel() in softcore(that is now turtleneedsfuel = 0) returned 9000.