Posted 09 December 2012 - 03:42 AM
Hi everyone!
I know things similar to this have been suggested quite some times, and people tend to just say:
"Ehrm…. You can use CCSensors to do this!" or "No magic in ComputerCraft".
This suggestion, however, contains no magic, can't be done with CCSensors and would greatly improve the turtles!
What should the API do?
The API should improve the interaction of turtles with adjacent inventories,
allowing the turtle to pull out items from a certain slot and so on.
The API should contain the following functions:
But why is this API really necessary?
Mainly, because the suck and drop functions there are at the moment don't allow the turtle to do anything complicated with inventories.
Refuel a furnace?
- Nope, can't put it into the bottom slot, if you just do turtle.drop(), the coal will go into the top slot.
You'll have to move your turtle below the furnace and do turtle.dropUp() then.
Take out items from another slot than just the first one?
- Really not possible. The only way to do something like that would be to suck up items until you have reached your slot count, and then drop all the items back in.
This is not really user- and turtle-friendly though, because it only works up to slot 16 of the inventory (because of the turtle's inventory size) and takes quite some time to do.
Take out just a few items from an inventory?
- Yes, but only in a hacky way, sucking the items out, transferTo some of them, and put the others back in.
Long story short, this API would make the interaction with inventories much easier, more comfortable and more reliable, and would allow easy interaction with furnaces or machines, without having to set up complicated piping systems everywhere just so your turtle can interact with it.
Magic, magic everywhere!
Nope, no magic.
There are no item or block IDs and everything listed could totally be done with something like a robot.
It would be extremely awesome if something like that could be implemented.
I know things similar to this have been suggested quite some times, and people tend to just say:
"Ehrm…. You can use CCSensors to do this!" or "No magic in ComputerCraft".
This suggestion, however, contains no magic, can't be done with CCSensors and would greatly improve the turtles!
What should the API do?
The API should improve the interaction of turtles with adjacent inventories,
allowing the turtle to pull out items from a certain slot and so on.
The API should contain the following functions:
inventory.getItemCount(side, slotNumber)
Returns how many of an item are in a certain slot in the inventory.
Returns 0, if there's nothing in the slot.
inventory.getItemSpace(side, slotNumber)
Similar to getItemCount, just returns how many items are missing to fill the stack up.
Returns 64 if there's air in the slot
inventory.slotEmpty(side, slotNumber)
Returns true if the slot is empty, false otherwise.
inventory.suck(side, slotNumber, [quantity])
Sucks out items from a slot in the inventory and fills them in the selected slot of the turtle. Takes out all items, if no quantity is given.
Returns true if the action succeeded.
inventory.drop(side, slotNumber, [quantity])
Drops items from the turtle's selected slot into a certain slot in the inventory. Drops all items, if no quantity is given.
Returns true if the action succeeded.
inventory.move(side, slot1, slot2, [quantity])
Moves items INSIDE the inventory from one slot to another.
Moves all items if no quantity is given.
Returns true if the action succeeded.
inventory.getSlotCount(side)
Returns a number how many slots there actually are.
But why is this API really necessary?
Mainly, because the suck and drop functions there are at the moment don't allow the turtle to do anything complicated with inventories.
Refuel a furnace?
- Nope, can't put it into the bottom slot, if you just do turtle.drop(), the coal will go into the top slot.
You'll have to move your turtle below the furnace and do turtle.dropUp() then.
Take out items from another slot than just the first one?
- Really not possible. The only way to do something like that would be to suck up items until you have reached your slot count, and then drop all the items back in.
This is not really user- and turtle-friendly though, because it only works up to slot 16 of the inventory (because of the turtle's inventory size) and takes quite some time to do.
Take out just a few items from an inventory?
- Yes, but only in a hacky way, sucking the items out, transferTo some of them, and put the others back in.
Long story short, this API would make the interaction with inventories much easier, more comfortable and more reliable, and would allow easy interaction with furnaces or machines, without having to set up complicated piping systems everywhere just so your turtle can interact with it.
Magic, magic everywhere!
Nope, no magic.
There are no item or block IDs and everything listed could totally be done with something like a robot.
It would be extremely awesome if something like that could be implemented.