Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local logFile = "/.me_items_log_tmp"
- local filterKeyword = "drawer" -- Change this keyword if needed
- local device = peripheral.find("meBridge")
- if not device then
- print("No ME Bridge found!")
- return
- end
- local success, items = pcall(device.listItems)
- if not success or type(items) ~= "table" then
- print("Error: Unable to retrieve listItems()")
- return
- end
- local file = fs.open(logFile, "w")
- file.writeLine("ME Bridge - listItems() Filtered Output (Keyword: " .. filterKeyword .. ")\n")
- local foundItems = false
- for slot, data in pairs(items) do
- -- Check if any field (name, displayName, tags, etc.) contains "drawer"
- local matchFound = false
- for key, value in pairs(data) do
- if type(value) == "string" and value:lower():match(filterKeyword) then
- matchFound = true
- break
- end
- end
- if matchFound then
- foundItems = true
- file.writeLine("Slot: " .. tostring(slot))
- for key, value in pairs(data) do
- if type(value) == "table" then
- local success, serialized = pcall(textutils.serialize, value)
- if success then
- file.writeLine(" " .. key .. " = " .. serialized)
- else
- file.writeLine(" " .. key .. " = [Unserializable Data]")
- end
- else
- file.writeLine(" " .. key .. " = " .. tostring(value))
- end
- end
- file.writeLine("-------------------")
- end
- end
- file.close()
- if not foundItems then
- print("\nNo items matching keyword '" .. filterKeyword .. "' found.")
- fs.delete(logFile)
- return
- end
- print("\nUploading to Pastebin...")
- local pastebinSuccess = shell.run("pastebin", "put", logFile)
- if pastebinSuccess then
- print("\nPastebin upload successful!")
- end
- fs.delete(logFile)
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement