items = turtle.getItemCount(1) + turtle.getItemCount(2) + turtle.getItemCount(3) + turtle.getItemCount(4) + turtle.getItemCount(5) + turtle.getItemCount(6) + turtle.getItemCount(7) + turtle.getItemCount(8) + turtle.getItemCount(9) + turtle.getItemCount(10) + turtle.getItemCount(11) + turtle.getItemCount(12) + turtle.getItemCount(13) + turtle.getItemCount(14) + turtle.getItemCount(15) + turtle.getItemCount(16)
As you can see this is quite lengthy and for this reason, I have not even tested this to see if it even works.
I came up with this then:
for i = 1, 16 do -- Scans each inventory slot
items = turtle.getItemCount(i)
end
I figured this would work because the variable i makes the function account for slots 1-16, yet when I use this in a larger code:
local function inventory()
local items = 0
for i = 1, 16 do --Scan every inventory slot
items = items + turtle.getItemCount(i)
end
print( items )
end
inventory()
I receive the error:
test:6: attempt to call number
Any help in fixing this would be much appreciated! :D/>