This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Cubstep12's profile picture

Turtle Acting Like An RP2 Filter?

Started by Cubstep12, 07 December 2012 - 05:21 AM
Cubstep12 #1
Posted 07 December 2012 - 06:21 AM
Is it possible to have a turtle only suck out certain items?
Sammich Lord #2
Posted 07 December 2012 - 06:23 AM
No, you will have to suck out all items, compare them, put back the items you don't want.
Cubstep12 #3
Posted 07 December 2012 - 06:26 AM
No, you will have to suck out all items, compare them, put back the items you don't want.
i am trying to use them to refill water buckets, is there any other way to do it witout turtles?
ChunLing #4
Posted 07 December 2012 - 08:12 AM
You can fill the turtles inventory with single item stacks of what you want, and then it only can suck what will stack with what it's got. Write a simple drop-all-but-one function so that you don't ever empty a slot completely. Of course this only works with items that stack.

You can fill water buckets with a dispenser nowadays (for those who didn't find performance issues in the recent minecraft upgrades sufficient to downgrade back to 1.2.5). There are probably mods that have yet other water bucket filling options.
GopherAtl #5
Posted 07 December 2012 - 08:37 AM
You can fill the turtles inventory with single item stacks of what you want, and then it only can suck what will stack with what it's got. […]

True, but, this works only for sucking up items dropped in the world around the turtle. When sucking from an inventory, if the first slot containing items doesn't contain something in the turtle's inventory, suck will just return false. Interesting side-effect, if the first stack was not in the first slot before, it will be after, implying the turtle is sucking the item out of the chest then putting it right back if it can't store it.

Even for drops, the behavior of suck() when the inventory is full is to pick up the first stack (oldest dropped) first. Then, if there is no inventory slot to put it in, it is dropped again, out the back of the turtle. Suck will still return true when this happens.