Difference between revisions of "Turtle.suck"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with "{{lowercase}} {{Function |name=turtle.suck |args= |returns=true if at least one item was moved into the turtle's inventory; false otherwise. |api=turtle |addon=ComputerCraft |...")
 
(Removing examples of other commands, keeping just the examples related to this command.)
 
(9 intermediate revisions by 8 users not shown)
Line 2: Line 2:
 
{{Function
 
{{Function
 
|name=turtle.suck
 
|name=turtle.suck
|args=
+
|args=[<nowiki></nowiki>{{type|number}} amount]
|returns=true if at least one item was moved into the turtle's inventory; false otherwise.
+
|returns={{type|boolean}} <var>true</var> if at least one item was moved into the turtle's inventory; <var>false</var> otherwise.
 
|api=turtle
 
|api=turtle
 
|addon=ComputerCraft
 
|addon=ComputerCraft
|desc=If an item is in the square directly in front of the turtle, it picks up one of those items.  
+
|desc=
If a chest is in the square directly in front of the turtle, it picks up the items from the first non-empty slot, moving from top left to bottom right.  
+
Moves one or more items from either the ground in front of the turtle, or, from an inventory-enabled block (such as a chest) in front of the turtle.
The items are moved into the currently selected slot, if there is room.  
+
* If an item is in the square directly in front of the turtle, it picks up one of those items.  
If the currently selected slot is filled up before all of the items are picked up, the remaining items are put in the next available slot.  
+
* If a chest is in the square directly in front of the turtle, it picks up the items from the first non-empty chest slot, moving from top left to bottom right. The items are moved into the currently selected turtle slot if there is room.  
If the currently selected slot is 16, it will loop around and try slot 1, and so on.
+
* If the currently selected turtle slot is filled up before all of the items are picked up, the remaining picked up items are put in the next available turtle slot.  
 
+
* If the currently selected turtle slot is 16 and the next slot is required, it will loop around and try turtle slot 1, and so on.
 +
* As of ComputerCraft 1.6, if an amount is specified, the turtle will attempt to pick up at most the specified number of items. Earlier builds always attempt to pick up a full slot.
 
|examples=
 
|examples=
 
{{Example
 
{{Example
|desc=Picks up some items.
+
|desc=Picks up some items from in front of the turtle.
|code=turtle.suck()
+
|code='''turtle.suck()'''
 
}}
 
}}
 
}}
 
}}
 +
 +
==See also==
 +
*[[turtle.suckUp]]
 +
*[[turtle.suckDown]]
 +
 +
[[Category:Lua_Core_Functions]]

Latest revision as of 20:50, 21 April 2015


Grid Redstone.png  Function turtle.suck
Moves one or more items from either the ground in front of the turtle, or, from an inventory-enabled block (such as a chest) in front of the turtle.
  • If an item is in the square directly in front of the turtle, it picks up one of those items.
  • If a chest is in the square directly in front of the turtle, it picks up the items from the first non-empty chest slot, moving from top left to bottom right. The items are moved into the currently selected turtle slot if there is room.
  • If the currently selected turtle slot is filled up before all of the items are picked up, the remaining picked up items are put in the next available turtle slot.
  • If the currently selected turtle slot is 16 and the next slot is required, it will loop around and try turtle slot 1, and so on.
  • As of ComputerCraft 1.6, if an amount is specified, the turtle will attempt to pick up at most the specified number of items. Earlier builds always attempt to pick up a full slot.
Syntax turtle.suck([number amount])
Returns boolean true if at least one item was moved into the turtle's inventory; false otherwise.
Part of ComputerCraft
API turtle

Examples

Grid paper.png  Example
Picks up some items from in front of the turtle.
Code
turtle.suck()


See also