gheotic, on 03 February 2013 - 10:09 AM, said:
but it hard to organise it that way :/
When you go to place saplings, or use bonemeal, or consume a fuel, just make it so your program considers each slot to be empty when it gets down to a count of 1 instead of 0. When, when you suck() from your refill chests, it will automatically refill matching items into those stacks. Or you can have separate refill chests for each item type, and dumping (using drop()) and select each designated slot before sucking items from the corresponding chest. I personally like the former approach, where you keep a reference item.
Either way, it will be simplest if you refill each item from a separate chest that contains only that item. I suggest this because you don't get to pick which chest slot suck() takes from, you just get whatever is in the chest's first empty slot, so in order to refill 2 or more item types from one chest and make sure you refill with some of each of the required items--
making no assumptions about how the chest is organized or sorted--you would have to suck from one chest into an empty turtle slot(s), use compareTo() and transferTo() against reference items to get things onto the right stacks, and then drop() unmatching items or items you've already got enough of into another chest so that you don't get in a loop where you keep sucking up and returning one item type over and over and never get all the things you need.