MagmaLP

Mobfarm Sortier-PC unten

Oct 31st, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- CONSTANTS
  2. local INTERVAL = 5
  3. local PIPE_SIDE = "bottom"
  4. local REQUEST_IDS = {
  5.  
  6. --Bow
  7. 261,
  8. 352,
  9. 262,
  10. 397,
  11. 367,
  12. 391,
  13. 341,
  14. 287,
  15. 262,
  16. 267,
  17. 256,
  18. 272,
  19.  
  20. 298,
  21. 299,
  22. 300,
  23. 301,
  24.  
  25. 302,
  26. 303,
  27. 304,
  28. 305,
  29.  
  30.  
  31. }
  32. -- IMPLEMENTATION
  33. function convertNBT(nbt)
  34.     local conv = {}
  35.     if (nbt == nil) then
  36.         return nil
  37.     elseif (nbt["type"] == "NBTTagCompound") or (nbt["type"] == "NBTTagList") then
  38.         for key, value in pairs(nbt["value"]) do
  39.             conv[key] = convertNBT(value)
  40.         end
  41.     else
  42.         conv = nbt["value"]
  43.     end
  44.     return conv
  45. end
  46.  
  47. function getItems(pipe)
  48.     pipe.getAvailableItems()
  49.     local event, result = os.pullEvent("available_items_return")
  50.     return result
  51. end
  52.  
  53. function inList(item)
  54.     for _, id in pairs(REQUEST_IDS) do
  55.         if item.id == id then
  56.             return true
  57.         end
  58.     end
  59.     return false
  60. end
  61.  
  62.  
  63. -- MAIN
  64. local pipe = peripheral.wrap(PIPE_SIDE)
  65. while true do
  66.     for i, result in pairs(getItems(pipe)) do
  67.         local iid, amount = unpack(result)
  68.         local item = {
  69.             id = pipe.getItemID(iid),
  70.             dmg = pipe.getItemDamage(iid),
  71.             nbt = convertNBT(pipe.getNBTTagCompound(iid))
  72.         }
  73.         if inList(item) then
  74.             pipe.makeRequest(iid, amount)
  75.             sleep(2)
  76.         end
  77.     end
  78.     sleep(INTERVAL)
  79. end
Add Comment
Please, Sign In to add comment