Difference between revisions of "Turtle.craft"
From ComputerCraft Wiki
(Changing int to number) |
Negamartin (Talk | contribs) (Added turtle.craft(0) functionality (please add min. version if it exists)) |
||
Line 11: | Line 11: | ||
Will not craft if there are any items in the turtle's inventory that are not part of the recipe, including in the slots not used for crafting. | Will not craft if there are any items in the turtle's inventory that are not part of the recipe, including in the slots not used for crafting. | ||
The produced items will appear in the selected slot, if that slot is free. If not, it will try the next available slot. | The produced items will appear in the selected slot, if that slot is free. If not, it will try the next available slot. | ||
− | A parameter can also be supplied to specify the quantity of items to craft. | + | A parameter can also be supplied to specify the quantity of items to craft. If the quantity specified is 0, will return true if a valid recipe has been found in the turtle's inventory, and false otherwise. |
|examples= | |examples= | ||
{{Example | {{Example | ||
|desc=Crafts as many items as possible | |desc=Crafts as many items as possible | ||
|code=print( turtle.craft() ) | |code=print( turtle.craft() ) | ||
− | |output=prints a {{type|boolean}} representing if | + | |output=prints a {{type|boolean}} representing if any items were crafted |
}} | }} | ||
{{Example | {{Example | ||
|desc=Crafts 5 items | |desc=Crafts 5 items | ||
|code=print(turtle.craft(5)) | |code=print(turtle.craft(5)) | ||
− | |output=prints a {{type|boolean}} representing if items were crafted | + | |output=prints a {{type|boolean}} representing if any items were crafted |
+ | }} | ||
+ | {{Example | ||
+ | |desc=Checks if the recipe is valid | ||
+ | |code=print(turtle.craft(0)) | ||
+ | |output=prints a {{type|boolean}} representing if the recipe is valid | ||
}} | }} | ||
}} | }} | ||
[[Category:Lua_Core_Functions]] | [[Category:Lua_Core_Functions]] |
Latest revision as of 19:23, 9 June 2015
Function turtle.craft | |
Requires a Crafty Turtle.
Crafts an item if items in the turtle's inventory matches a valid recipe. The items can be placed anywhere as long as they are oriented properly with respect to one another. Can craft a maximum of one stack of items at a time; for example, if you put three stacks of 64 reed in a line and craft them, only 63 paper will be crafted, and three piles of 43 reed will remain in the turtle. Will not craft if there are any items in the turtle's inventory that are not part of the recipe, including in the slots not used for crafting. The produced items will appear in the selected slot, if that slot is free. If not, it will try the next available slot. A parameter can also be supplied to specify the quantity of items to craft. If the quantity specified is 0, will return true if a valid recipe has been found in the turtle's inventory, and false otherwise. | |
Syntax | turtle.craft(number quantity ( if not supplied will craft as many as possible )) |
Returns | boolean if an item was crafted |
Part of | ComputerCraft |
API | turtle |
Examples
Example | |
Crafts as many items as possible | |
Code |
print( turtle.craft() ) |
Output | prints a boolean representing if any items were crafted |
Example | |
Crafts 5 items | |
Code |
print(turtle.craft(5)) |
Output | prints a boolean representing if any items were crafted |
Example | |
Checks if the recipe is valid | |
Code |
print(turtle.craft(0)) |
Output | prints a boolean representing if the recipe is valid |