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

[Lua][Turtle][Programming] pull x amount of items from inventory?

Started by fusiomax, 30 September 2012 - 07:54 AM
fusiomax #1
Posted 30 September 2012 - 09:54 AM
So I'm making a tree farm program, a pretty simple one, a set area that it farms trees on.

Now I need to make sure that it has enough saplings to replant the the trees it cuts down (there are 8 trees so needs a minimum of 8 saplings at any one time) So I can make it check that it has at least 8 saplings and if it doesn't get it to pull from a chest, but is it possible to make the turtle only pull 32 from the chest?

I've been thinking about it and I can't seem to figure a way to do it (other than making sure that there are only 32 saplings in the chest at any one time using some redpower magic).

Any help you can give me would be much appreciated :)/>/>
Lyqyd #2
Posted 30 September 2012 - 10:31 AM
Pull a bunch out, put the extras back.
fusiomax #3
Posted 30 September 2012 - 10:41 AM
Pull a bunch out, put the extras back.

that would work in this situation but other situations this may not be viable, is there anyway that I can just pull x amount from a container even if it means programming an extra function?
jag #4
Posted 30 September 2012 - 03:27 PM
How are you picking out the saplings?
Lyqyd #5
Posted 30 September 2012 - 07:06 PM
Pull a bunch out, put the extras back.

that would work in this situation but other situations this may not be viable, is there anyway that I can just pull x amount from a container even if it means programming an extra function?

That is the way to pull n items out. Just keep track of how much stuff is in each slot, suck from the chest, then put back any extras based on how much stuff is now in each slot.