Turtle API

Revision as of 01:13, 25 December 2012 by Mastergalen (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Turtles have a set of commands that are part of the Lua programming language. Use these commands when writing turtle programs to get the turtle to move, dig, place blocks, and so forth.

Methods

KEY
Color Turtles that can perform this
Gray All
Green Crafting
Yellow Mining, Felling, Digging, Farming
Red Any tool


Method name Description Return type
turtle.craft() Craft items using ingredients in the nine upper left slots bool "success"
turtle.forward() Let the Turtle move forward bool "success"
turtle.back() Let the Turtle move back bool "success"
turtle.up() Let the Turtle move up bool "success"
turtle.down() Let the Turtle move down bool "success"
turtle.turnLeft() The Turtle turns left bool "true"
turtle.turnRight() The Turtle turns right bool "true"
turtle.select( slotNum ) The Turtle selects the given Slot (1 is top left, 16 (9 in 1.33 and earlier) is bottom right) bool "slot > 16"
turtle.getItemCount( slotNum ) Counts how many items are in the given Slot int "result"
turtle.getItemSpace( slotNum ) Counts how many items you need to fill the stack in the given Slot int "result"
turtle.attack() Attacks in front of the turtle bool "success"
turtle.attackUp() Attacks over the turtle bool "success"
turtle.attackDown() Attacks under the turtle bool "success"
tunnel ([length]) Digs a tunnel 2 blocks tall and 3 wide with a specified length. bool "success"
turtle.dig() Breaks the Block in front. With hoe: tills the dirt in front of it. bool "success"
turtle.digUp() Breaks the Block Above it. With hoe: tills the dirt above it. bool "success"
turtle.digDown() Breaks the Block Below it. With hoe: tills the dirt below it. bool "success"
turtle.place([signText]) Places a Block of the selected Slot in front. Engrave [signText] on signs if provided. nil
turtle.placeUp() Places a Block of the selected Slot above nil
turtle.placeDown() Places a Block of the selected Slot below nil
turtle.detect() Detects if there is a Block in front bool "result"
turtle.detectUp() Detects if there is a Block above bool "result"
turtle.detectDown() Detects if there is a Block below bool "result"
turtle.compare() Detects if the block in front is the same as the one in the selected Slot bool "result"
turtle.compareUp() Detects if the block above is the same as the one in the selected Slot bool "result"
turtle.compareDown() Detects if the block below is the same as the one in the selected Slot bool "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 bool "result"
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.

bool "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.

bool "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.

bool "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. bool "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. bool "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 bool "success"
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 needfuel mode. If the current slot doesn't contain a fuel item, it yields false. bool "success"
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".

int "fuel"

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

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Need wiki hosting?

Do you need a wiki for your Minecraft mod/gaming wiki? We'll host it for free! Contact us.

Other wikis

Indie-game wikis
Powered by Indie Wikis