Jump to content




Best Way To "turtle.suck()" Specific Amount of Items


  • You cannot reply to this topic
7 replies to this topic

#1 elfin8er

  • Members
  • 133 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 by elfin8er, 14 January 2014 - 10:06 PM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (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.

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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.

#4 elfin8er

  • Members
  • 133 posts

Posted 15 January 2014 - 10:16 PM

View PostBomb Bloke, on 14 January 2014 - 11:10 PM, said:

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.

#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (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.

#6 elfin8er

  • Members
  • 133 posts

Posted 16 January 2014 - 01:05 AM

View PostBomb Bloke, on 15 January 2014 - 11:29 PM, said:

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.

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 January 2014 - 01:08 AM

View Postelfin8er, on 16 January 2014 - 01:05 AM, said:

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 by theoriginalbit, 16 January 2014 - 01:09 AM.


#8 elfin8er

  • Members
  • 133 posts

Posted 16 January 2014 - 01:14 AM

View Posttheoriginalbit, on 16 January 2014 - 01:08 AM, said:

View Postelfin8er, on 16 January 2014 - 01:05 AM, said:

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.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users