Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local im = peripheral.find("inventoryManager")
- local cb = peripheral.find("chatBox")
- if im == nil then error("The inventory manager is not found") end
- if cb == nil then error("Chatbox not found") end
- print("Running Dumper")
- while true do
- local e, player, msg = os.pullEvent("chat")
- if msg == "e" and player == "TheMonkeDuo" then
- print("Dumping slots 9 through 26")
- local myInv = im.getItems()
- local foo = {}
- for k, v in pairs(myInv) do
- if type(v) == "table" and v.count then
- foo[k] = v.count
- print("Stored count for slot " .. k .. ": " .. v.count)
- else
- print("Error: Expected a table with a count field at slot " .. k)
- end
- end
- for k, v in pairs(foo) do
- if k >= 9 and k <= 26 then
- print(k .. ": " .. v)
- -- Attempt to remove items assuming a common method signature
- local success, err = pcall(function() im.removeItemFromPlayer("bottom", { slot = k, quantity = v }) end)
- if not success then
- print("Failed to remove items from slot " .. k .. ": " .. err)
- else
- print("Removed " .. v .. " items from slot " .. k)
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment