Turtle API
The turtle API is exclusive to turtles and advanced turtles.
|
|||||||||||
Attacks the entity in direction and range | |||||||||||
Syntax | turtle.attack(
|
||||||||||
Returns | bool didAttack | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Attacks the entity under the turtle | |||||||||||
Syntax | turtle.attackDown(
|
||||||||||
Returns | bool didAttack | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Attacks the entity over the turtle | |||||||||||
Syntax | turtle.attackUp(
|
||||||||||
Returns | bool didAttack | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||
When called, tries to move the turtle backwards 1 block in the direction it is facing. The function will return false if the destination is obstructed or protected, or if the turtle is out of fuel.
|
|||||||||
Syntax | turtle.back() | ||||||||
Returns | boolean success [, string error ] | ||||||||
Part of | CC:Tweaked (source) | ||||||||
API | turtle | ||||||||
|
Turtle.compare Turtle.compareDown Turtle.compareTo Turtle.compareUp
|
|||
Requires the turtle to have a crafting table equipped.
Crafts items if the turtle's inventory contains a valid recipe and nothing else. It is not limited to the top-left nine slots - as long as its inventory contains the necessary pattern of items and is free of any other items (including ones outside of the space the crafting pattern occupies), it can craft. Produced items will fill the selected slot preferentially and the ones after it if it is full. It is not limited to crafting a single stack at once - for example, if you put a stack of redstone blocks in a turtle and execute this, nine stacks of redstone will be produced. The argument "limit" limits the amount of times the crafting recipe will be made. If enough items to make it multiple times are provided, but a limit lower than this is specified, it will make the recipe the specified amount of times and leave the remaining items in their places. If "limit" is 0, it will return false and the second return value will contain the error message. For example, if the turtle does not contain a valid recipe when this is executed, it will return false and "No matching recipes" . If crafting is successful it will return only true . |
|||
Syntax | turtle.craft(
|
||
Returns | boolean true | boolean false, string | ||
Part of | CC:Tweaked (source) | ||
API | turtle |
|
|||||||||||
When called, will return true if the block in front of the turtle is anything that is not air or liquid. | |||||||||||
Syntax | turtle.detect() | ||||||||||
Returns | boolean result | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
When called, will return true if the block below the turtle is anything that is not air or liquid. | |||||||||||
Syntax | turtle.detectDown() | ||||||||||
Returns | boolean result | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
When called, will return true if the block above the turtle is anything that is not air or liquid. | |||||||||||
Syntax | turtle.detectUp() | ||||||||||
Returns | boolean result | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Breaks the block in front of the turtle. | |||||||||||
Syntax | turtle.dig(
|
||||||||||
Returns | bool didDig | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Breaks the block in beneath the turtle. | |||||||||||
Syntax | turtle.digDown(
|
||||||||||
Returns | bool didDig | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Breaks the block above the turtle. | |||||||||||
Syntax | turtle.digUp(
|
||||||||||
Returns | bool didDig | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||
When called, tries to move the turtle down 1 block. The function will return false if the destination is obstructed or protected, or if the turtle is out of fuel.
|
|||||||||
Syntax | turtle.down() | ||||||||
Returns | boolean success [, string error ] | ||||||||
Part of | CC:Tweaked (source) | ||||||||
API | turtle | ||||||||
|
|
|||||||||||
Drops the item item in the turtle’s selected slot in front of the turtle. | |||||||||||
Syntax | turtle.drop() | ||||||||||
Returns | boolean success | ||||||||||
Part of | Lua (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Drops the item item in the turtle’s selected slot below the turtle. | |||||||||||
Syntax | turtle.dropDown() | ||||||||||
Returns | boolean success | ||||||||||
Part of | Lua (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Drops the item item in the turtle’s selected slot above the turtle. | |||||||||||
Syntax | turtle.dropUp() | ||||||||||
Returns | boolean success | ||||||||||
Part of | Lua (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||
When called, will equip the item currently selected onto the left side of the turtle. If no item is selected, it will dequip the item on the left side. | |||||||||
Syntax | turtle.equipLeft() | ||||||||
Returns | boolean success | ||||||||
Part of | CC:Tweaked (source) | ||||||||
API | turtle | ||||||||
|
|
|||||||||
When called, will equip the item currently selected onto the right side of the turtle. If no item is selected, it will dequip the item on the right side. | |||||||||
Syntax | turtle.equipRight() | ||||||||
Returns | boolean success | ||||||||
Part of | CC:Tweaked (source) | ||||||||
API | turtle | ||||||||
|
|
|||||||||
When called, tries to move the turtle forward 1 block in the direction it is facing. The function will return false if the destination is obstructed or protected, or if the turtle is out of fuel.
|
|||||||||
Syntax | turtle.forward() | ||||||||
Returns | boolean success [, string error ] | ||||||||
Part of | CC:Tweaked (source) | ||||||||
API | turtle | ||||||||
|
|
|||||||||||
Returns a number representing the current amount of fuel (block moves) the turtle currently holds. | |||||||||||
Syntax | turtle.getFuelLevel() | ||||||||||
Returns | number fuel | ||||||||||
Part of | CC:Tweaked | ||||||||||
API | turtle | ||||||||||
| |||||||||||
|
|
|||||||||||
Returns a number representing the maximum amount of fuel (block moves) the turtle can possibly hold. | |||||||||||
Syntax | turtle.getFuelLimit() | ||||||||||
Returns | number fuel | ||||||||||
Part of | CC:Tweaked | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Get the number of items in a slot. It will use the current selected slot, if slot is not specified. | |||||||||||
Syntax | turtle.getItemCount(
|
||||||||||
Returns | number count | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
Turtle.getItemDetail Turtle.getItemSpace
|
|||||||||||
Returns the currently selected item slot. | |||||||||||
Syntax | turtle.getSelectedSlot() | ||||||||||
Returns | number slot | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | turtle | ||||||||||
|
Turtle.inspect Turtle.inspectDown Turtle.inspectUp
|
|||||||||||
Places a block in the turtle’s selected slot in front of the turtle. | |||||||||||
Syntax | turtle.place() | ||||||||||
Returns | boolean success | ||||||||||
Part of | Lua (source) | ||||||||||
API | peripheral | ||||||||||
|
|
|||||||||||
Places a block in the turtle’s selected slot below the turtle. | |||||||||||
Syntax | turtle.placeDown() | ||||||||||
Returns | boolean success | ||||||||||
Part of | Lua (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Places the block in the turtle’s selected slot above the turtle. | |||||||||||
Syntax | turtle.placeUp() | ||||||||||
Returns | boolean success | ||||||||||
Part of | Lua (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||
This function attempts to refuel the turtle by consuming amount items from the currently selected slot. If no argument is supplied, it defaults to consuming the whole stack in the slot selected. |
|||||||||
Syntax | turtle.refuel(
|
||||||||
Returns | boolean | ||||||||
API | turtle | ||||||||
See also | turtle.getFuelLevel | ||||||||
| |||||||||
|
|
|||||||||
Sets the currently selected slot to slot |
|||||||||
Syntax | turtle.select(
|
||||||||
API | turtle | ||||||||
|
|
|||||||||||
Picks up a item in front of the turtle | |||||||||||
Syntax | turtle.place() | ||||||||||
Returns | integer amount | ||||||||||
Part of | Lua (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Picks up a item below the turtle | |||||||||||
Syntax | turtle.suckDown() | ||||||||||
Returns | integer amount | ||||||||||
Part of | Lua (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||||
Picks up a item above the turtle | |||||||||||
Syntax | turtle.place() | ||||||||||
Returns | integer amount | ||||||||||
Part of | Lua (source) | ||||||||||
API | turtle | ||||||||||
|
|
|||||||||
Moves an item to another slot. If quantity is empty, it will move the full stack. | |||||||||
Syntax | turtle.transferTo(
|
||||||||
Returns | boolean success | ||||||||
Part of | CC:Tweaked (source) | ||||||||
API | turtle | ||||||||
|
|
|||||||||
When called, tries to rotate the turtle 90 degrees to the left. Note that performing this action does not require fuel, and the turtle can not be obstructed or denied from rotating, unless specifically disabled in the config. | |||||||||
Syntax | turtle.turnLeft() | ||||||||
Returns | boolean success | ||||||||
Part of | CC:Tweaked (source) | ||||||||
API | turtle | ||||||||
|
|
|||||||||
When called, tries to rotate the turtle 90 degrees to the right. Note that performing this action does not require fuel, and the turtle can not be obstructed or denied from rotating, unless specifically disabled in the config. | |||||||||
Syntax | turtle.turnRight() | ||||||||
Returns | boolean success | ||||||||
Part of | CC:Tweaked (source) | ||||||||
API | turtle | ||||||||
|
|
|||||||||
When called, tries to move the turtle up 1 block. The function will return false if the destination is obstructed or protected, or if the turtle is out of fuel.
|
|||||||||
Syntax | turtle.up() | ||||||||
Returns | boolean success [, string error ] | ||||||||
Part of | CC:Tweaked (source) | ||||||||
API | turtle | ||||||||
|