I'm trying to get a list of items that are in the chest using .GetItemMeta(). Specifically I'm trying to print the Slot, Display Name and Itemcount to the right monitor. I get an error when attempting to run the code
test.lua:7: attempt to concatenate field 'count' (a nil value)
Below is the full code I'm trying to run
monitor = peripheral.wrap("right")
chest = peripheral.wrap("left")
y = 1
for slot, item in pairs(chest.getItemMeta(y)) do
monitor.setCursorPos(1, y)
monitor.write(y .. " " .. item.displayName .. " " .. item.count)
y = y + 1
end
Any help would be greatly appreciated :)
Quote from: DrStein on Jul 05, 2020, 07:05 AMmonitor.write(y .. " " .. item.displayName .. " " .. item.count)
replace
monitor.write(y .. " " .. item.displayName .. " " .. item.count)
with
monitor.write(y .. " " .. item.displayName .. " " .. item.count or 1)
Quote from: pjals on Jul 05, 2020, 11:22 AM-snip-
That won't work - you'd need to do (
item.count or 1). However, this whole thing is a bit strange - count should
never be missing. It might be worth doing
print(textutils.serialize(item)), and seeing what properties it has.