3 posts
Posted 24 February 2013 - 03:49 AM
Title: "[Lua][Question] How to suck a specified number of items out of a chest?
Title sums it up really, but I was wondering if there was a way to pull a certain number of items out if a chest. For example I was trying to use turtle.suck(4), however this pulls out as many as it can from the first slot,
Is this supposed to happen or is it a bug?
Also any differant idea's on how to do this?
Thanks
-Bancey
1511 posts
Location
Pennsylvania
Posted 24 February 2013 - 10:44 AM
This is not a bug, however, I believe the mod MiscPeripherals by RichardG allows more in depth "inventory management" methods
3 posts
Posted 25 February 2013 - 04:50 AM
Ah, got it. I'll have a look into it but this seams to be able to do waht I want.
Thanks :D/>
7508 posts
Location
Australia
Posted 25 February 2013 - 04:59 AM
Also you could do this.
turtle.suck() -- gets all items
local wanted = 24
local actuallyGot = turtle.getItemCount( 1 ) -- where one is the slot we just sucked into
if actuallyGot - wanted == 0 then
print("We got the perfect amount")
elseif actuallyGot - wanted > 0 then
turtle.drop( actuallyGot - wanted ) -- drop off the excess
else
print("We didn't get as many as we wanted :(/>")
end
1511 posts
Location
Pennsylvania
Posted 25 February 2013 - 07:19 AM
Also you could do this.
turtle.suck() -- gets all items
local wanted = 24
local actuallyGot = turtle.getItemCount( 1 ) -- where one is the slot we just sucked into
if actuallyGot - wanted == 0 then
print("We got the perfect amount")
elseif actuallyGot - wanted > 0 then
turtle.drop( actuallyGot - wanted ) -- drop off the excess
else
print("We didn't get as many as we wanted :(/>/>/>")
end
Pretty good solution actually :)/>/> not that I expected anything less from BIT :D/>