Posted 18 March 2013 - 02:25 AM
To make life much easier on programmers, a new API node should be added as an alternate way to craft items within turtles. The new API command would look something like this: "turtle.craft(slot, itemId, amount)" The 'slot' argument would be the slot that the items crafted would be placed in (up to 64). You would call the turtle to craft the specified itemId by entering the slot you wanted the crafted items placed and the amount. The API would then check all the slots of the turtle for the materials needed to craft the item, if a recipe exists. Upon crafting, the items used would be taken from the turtles inventory. This would make life much better for us programmers out there! Here is an example of code that would craft 72 fences (for my automatic mining program I wrote).
User places wood logs in first few slots.
This code would turn the logs into the amount of needed planks(108), taking up slots 5 and 6.
:turtle.craft(5, 5, 64)
:turtle.craft(6, 5, 44)
This code would turn the planks into sticks(216).
:turtle.craft(7, 280, 64)
:turtle.craft(8, 280, 64)
:turtle.craft(9, 280, 64)
:turtle.craft(10, 280, 24)
This code would then complete the program by turning the sticks into wooden fences.
:turtle.craft(13, 85, 64)
:turtle.craft(14, 85, 8)
The turtle has now crafted 72 fences from the stack of logs placed in the inventory by the user. In the end, (if the user placed exactly 27 logs in the first few slots) only slots 13 and 14 have items in them, (fences) that can now be placed by the turtle to create any structure the programmer wants. This API would greatly benefit the coders, and users. All anyone would need to do to run my advanced mine program would be to place a few stacks of wood in the first few spots, and some fuel, and the turtle will be able to create fences, fence gates, wooden planks, chests and more! In the current API, this type of behavior would be difficult to achieve, as every single slot must be empty except for the crafting recipe.
User places wood logs in first few slots.
This code would turn the logs into the amount of needed planks(108), taking up slots 5 and 6.
:turtle.craft(5, 5, 64)
:turtle.craft(6, 5, 44)
This code would turn the planks into sticks(216).
:turtle.craft(7, 280, 64)
:turtle.craft(8, 280, 64)
:turtle.craft(9, 280, 64)
:turtle.craft(10, 280, 24)
This code would then complete the program by turning the sticks into wooden fences.
:turtle.craft(13, 85, 64)
:turtle.craft(14, 85, 8)
The turtle has now crafted 72 fences from the stack of logs placed in the inventory by the user. In the end, (if the user placed exactly 27 logs in the first few slots) only slots 13 and 14 have items in them, (fences) that can now be placed by the turtle to create any structure the programmer wants. This API would greatly benefit the coders, and users. All anyone would need to do to run my advanced mine program would be to place a few stacks of wood in the first few spots, and some fuel, and the turtle will be able to create fences, fence gates, wooden planks, chests and more! In the current API, this type of behavior would be difficult to achieve, as every single slot must be empty except for the crafting recipe.