Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local invMgr = peripheral.find("inventory_manager")
- if not invMgr then error("Manager not found") end
- print("Testing listChest()...")
- -- 1. Try running the function
- -- We assume it takes no arguments (scans the attached chest)
- -- If it errors, we might need to give it a direction like "north"
- local success, data = pcall(invMgr.getItemsChest)
- if not success then
- print("Error calling function: " .. tostring(data))
- print("Trying with direction 'front'...")
- -- Some versions require a direction
- data = invMgr.getItemsChest("front")
- end
- -- 2. Check what we got back
- if type(data) ~= "table" then
- print("Function did not return a list! Got: " .. type(data))
- return
- end
- print("Received a list of items.")
- -- 3. Look at the first item to see if NBT is there
- for slot, item in pairs(data) do
- print("--- Item in Slot " .. slot .. " ---")
- print("Name: " .. (item.name or "Unknown"))
- if item.nbt then
- print("NBT found!")
- print(textutils.serialize(item.nbt))
- else
- print("No NBT table found in this list.")
- end
- -- Stop after the first one so we don't spam the screen
- break
- end
Advertisement
Add Comment
Please, Sign In to add comment