Posted 08 November 2013 - 10:12 PM
This is the code directly from the OpenPeripheral documentation page to get the inventory size. It's worth noting that I don't have a startup program or any program that changes anything before this code is run.
here is my code. it "attempts to call nil at line 4"
local stringInfo = pIM.getInvName()
print(stringInfo)
here is my code. it "attempts to call nil at line 4"
local chest = peripheral.wrap("front")
local pIM = peripheral.wrap("left")
chest.swapStacks(1,2)
local cSize = chest.getSizeInventory() -- line 4 is here
local pInvSize = pIM.getSizeInventory()
for i = 1, pIM.getSizeInventory() do
local tableInfo = pIM.getStackInSlot(i)
if pIM.getStackInSlot(i) then
for key, value in pairs(tableInfo) do
--print(key .. " = " .. tostring(value))
if key == "name" then
print("slot "..i.." contains "..value)
end
end
end
end
Edited on 08 November 2013 - 09:18 PM