Advertisement
Loneranger419

listCells

Feb 1st, 2025 (edited)
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. local logFile = "/.me_cells_log_tmp" -- Temporary file
  2.  
  3. local device = peripheral.find("meBridge")
  4.  
  5. if not device then
  6.     print("No ME Bridge found!")
  7.     return
  8. end
  9.  
  10. local success, cells = pcall(device.listCells)
  11.  
  12. if not success or type(cells) ~= "table" then
  13.     print("Error: Unable to retrieve listCells()")
  14.     return
  15. end
  16.  
  17. local file = fs.open(logFile, "w")
  18. file.writeLine("ME Bridge - listCells() Output:\n")
  19.  
  20. for slot, data in pairs(cells) do
  21.     file.writeLine("Cell Slot: " .. tostring(slot))
  22.    
  23.     for key, value in pairs(data) do
  24.         if type(value) == "table" then
  25.             local success, serialized = pcall(textutils.serialize, value)
  26.             if success then
  27.                 file.writeLine("  " .. key .. " = " .. serialized)
  28.             else
  29.                 file.writeLine("  " .. key .. " = [Unserializable Data]")
  30.             end
  31.         else
  32.             file.writeLine("  " .. key .. " = " .. tostring(value))
  33.         end
  34.     end
  35.     file.writeLine("-------------------")
  36. end
  37.  
  38. file.close()
  39.  
  40. print("\nUploading to Pastebin...")
  41. local success = shell.run("pastebin", "put", logFile)
  42.  
  43. if success then
  44.     print("\nPastebin upload successful!")
  45. end
  46.  
  47. fs.delete(logFile) -- Remove temporary file
  48. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement