132 posts
Posted 14 January 2014 - 10:04 PM
I'm trying to get a mining turtle to suck a specific amount of items out of a chest, move to a location, and drop them all out. Here's the code that I have.
amount = 15
while turtle.getItemCount(1) == 0 do
turtle.suck()
turtle.drop(turtle.getItemCount(1) - amount
end
Also, is there anyway that the turtle can take from other slots in the chest, or does it only take from the first slot? I already know that everything in the chest is the same item. I just need to be able to take a specific amount of items from the chest.
Edited on 14 January 2014 - 09:06 PM
7083 posts
Location
Tasmania (AU)
Posted 14 January 2014 - 11:10 PM
OpenPeripherals allows this. You wrap the chest as a peripheral, then tell the chest itself to move the items to the turtle. This allows you to specify which slot and how many items.
Some documentation is
here, but it may or may not match your installed version.
7508 posts
Location
Australia
Posted 14 January 2014 - 11:28 PM
the way you've done it is definitely the only way to do it in the current version of ComputerCraft (
soon to change) without installing peripheral mods such as OpenPeripheral like Bomb Bloke stated.
This functionality is however changing in the new version of ComputerCraft where you'll be able to use turtle.suck with a quantity argument.
132 posts
Posted 15 January 2014 - 10:16 PM
OpenPeripherals allows this. You wrap the chest as a peripheral, then tell the chest itself to move the items to the turtle. This allows you to specify which slot and how many items.
Some documentation is
here, but it may or may not match your installed version.
Awesome, thanks! Woah there. I just noticed you're the same person that replied a question of mine on the FTB forums.
7083 posts
Location
Tasmania (AU)
Posted 15 January 2014 - 11:29 PM
Ah. The same question, I see. I thought it was a little bit of a coincidence to see it asked twice over a couple of days.
132 posts
Posted 16 January 2014 - 01:05 AM
Ah. The same question, I see. I thought it was a little bit of a coincidence to see it asked twice over a couple of days.
Yea, slightly different, but same idea. While you're here, do you know of an easy way I don't have to specify which slot? I'm having a bit of trouble with it.
7508 posts
Location
Australia
Posted 16 January 2014 - 01:08 AM
While you're here, do you know of an easy way I don't have to specify which slot? I'm having a bit of trouble with it.
turtle.suck will suck the items into the currently selected slot; or the next available slot in the event that the currently selected is full or the stack cannot become larger. As such just change to the slot you wish to suck into…
If you mean in relation to OpenPeripheral, nope, there's no way to perform a item movement without specifying the slot to take from.
Edited on 16 January 2014 - 12:09 AM
132 posts
Posted 16 January 2014 - 01:14 AM
While you're here, do you know of an easy way I don't have to specify which slot? I'm having a bit of trouble with it.
If you mean in relation to OpenPeripheral, nope, there's no way to perform a item movement without specifying the slot to take from.
Ok, I guess I'll have to write my own function to do it then.