mlard811

Untitled

Jan 10th, 2026 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. local invMgr = peripheral.find("inventory_manager")
  2.  
  3. if not invMgr then error("Manager not found") end
  4.  
  5. print("Testing listChest()...")
  6.  
  7. -- 1. Try running the function
  8. -- We assume it takes no arguments (scans the attached chest)
  9. -- If it errors, we might need to give it a direction like "north"
  10. local success, data = pcall(invMgr.getItemsChest)
  11.  
  12. if not success then
  13.     print("Error calling function: " .. tostring(data))
  14.     print("Trying with direction 'front'...")
  15.     -- Some versions require a direction
  16.     data = invMgr.getItemsChest("front")
  17. end
  18.  
  19. -- 2. Check what we got back
  20. if type(data) ~= "table" then
  21.     print("Function did not return a list! Got: " .. type(data))
  22.     return
  23. end
  24.  
  25. print("Received a list of items.")
  26.  
  27. -- 3. Look at the first item to see if NBT is there
  28. for slot, item in pairs(data) do
  29.     print("--- Item in Slot " .. slot .. " ---")
  30.     print("Name: " .. (item.name or "Unknown"))
  31.    
  32.     if item.nbt then
  33.         print("NBT found!")
  34.         print(textutils.serialize(item.nbt))
  35.     else
  36.         print("No NBT table found in this list.")
  37.     end
  38.    
  39.     -- Stop after the first one so we don't spam the screen
  40.     break
  41. end
Advertisement
Add Comment
Please, Sign In to add comment