DorianH935

Untitled

Jul 13th, 2024 (edited)
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. local im = peripheral.find("inventoryManager")
  2. local cb = peripheral.find("chatBox")
  3.  
  4. if im == nil then error("The inventory manager is not found") end
  5. if cb == nil then error("Chatbox not found") end
  6.  
  7. print("Running Dumper")
  8.  
  9. while true do
  10. local e, player, msg = os.pullEvent("chat")
  11. if msg == "e" and player == "TheMonkeDuo" then
  12. print("Dumping slots 9 through 26")
  13. local myInv = im.getItems()
  14. local foo = {}
  15.  
  16. for k, v in pairs(myInv) do
  17. if type(v) == "table" and v.count then
  18. foo[k] = v.count
  19. print("Stored count for slot " .. k .. ": " .. v.count)
  20. else
  21. print("Error: Expected a table with a count field at slot " .. k)
  22. end
  23. end
  24.  
  25. for k, v in pairs(foo) do
  26. if k >= 9 and k <= 26 then
  27. print(k .. ": " .. v)
  28. -- Attempt to remove items assuming a common method signature
  29. local success, err = pcall(function() im.removeItemFromPlayer("bottom", { slot = k, quantity = v }) end)
  30. if not success then
  31. print("Failed to remove items from slot " .. k .. ": " .. err)
  32. else
  33. print("Removed " .. v .. " items from slot " .. k)
  34. end
  35. end
  36. end
  37. end
  38. end
  39.  
Add Comment
Please, Sign In to add comment