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

Item counting problems

Started by AaronFranz, 28 September 2014 - 09:20 PM
AaronFranz #1
Posted 28 September 2014 - 11:20 PM
Hi, I am trying to make a turtle program that will pull items from one chest count it and put it into another chest.
And of course I am having no luck at all; or I wouldn't be here. ;)/>

here is the code.

i = 0
while true do
turtle.suck()
turtle.getItemCount() = b
i = i + b
term.clear()
term.setCursorPos(1,1)
print("You have ")
print("..i..")
print(" peices.")
end
Lyqyd #2
Posted 28 September 2014 - 11:30 PM
You were close. You had your assignment in the wrong order, and weren't taking full advantage of the second variable.


local count = 0
local lastSucked = 1
turtle.select(1)

while lastSucked >= 0 do
  turtle.suck()
  lastSucked = turtle.getItemCount(1)
  count = count + lastSucked
  turtle.dropDown()
end

term.clear()
term.setCursorPos(1, 1)
print("You have "..count.." pieces.")
AaronFranz #3
Posted 30 September 2014 - 05:58 AM
Thank you, I will put this code in and see how it works. :)/>