MagmaLP

Me entleerung mit Logistic

Oct 31st, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- CONSTANTS
  2. local INTERVAL = 120
  3. local PIPE_SIDE = "bottom"
  4. local REQUEST_IDS = {
  5.  
  6. --Swords      
  7. 267,   --Iron
  8. 268,   --Wood
  9. 272,   --Stone
  10. 276,   --Diamond
  11. 283,   --Gold
  12. 4369,  --Quarz
  13. 5648,  --Green Sapphire
  14. 5649,  --Ruby
  15. 5650,  --Blue Sapphire
  16. 30198, --Bronze
  17.  
  18. --Pickaxe
  19. 257,   --Iron
  20. 270,   --Wood
  21. 274,   --Stone
  22. 278,   --Diamond
  23. 285,   --Gold
  24. 4368,  --Quarz
  25. 5633,  --Green Sapphire
  26. 5634,  --Ruby
  27. 5635,  --Blue Sapphire
  28. 30200, --Bronze
  29.  
  30. --Axe
  31. 258,   --Iron
  32. 271,   --Wooden
  33. 275,   --Stone
  34. 279,   --Dia
  35. 286,   --Gold
  36. 4365,  --Quarz
  37. 5590,  --Green Sapphine
  38. 5591,  --Ruby
  39. 5592,  --Blue Sapphire
  40. 30199, --Bronze
  41.  
  42. --Shovel
  43. 256,   --Iron
  44. 269,   --Wooden
  45. 273,   --Stone
  46. 277,   --Dia
  47. 284,   --Gold
  48. 4367,  --Quarz
  49. 5637,  --Green Sapphire
  50. 5638,  --Ruby
  51. 5639,  --Blue Sapphire
  52. 30197, --Bronze
  53.  
  54. --Battle Axe
  55. 11532, --Iron
  56. 11530, --Wooden
  57. 11531, --Stone
  58. 11533, --Dia
  59. 11534, --Gold
  60.  
  61. --Hoe
  62. 292,   --Iron
  63. 290,   --Wood
  64. 291,   --Stone
  65. 293,   --Dia
  66. 294,   --Gold
  67. 4366,  --Quarz
  68. 5593,  --Green Sapphire
  69. 5597,  --Ruby
  70. 5598,  --Blue Sapphire
  71. 30196, --Bronze
  72.  
  73. --Warhammer
  74. 11537, --Iron
  75. 11535, --Wooden
  76. 11536, --Stone
  77. 11538, --Dia
  78. 11539, --Gold
  79.  
  80. 5577, --Diamond Handsaw
  81. 261,  --Bow
  82. 11555,--Crossbow
  83. }
  84.  
  85.  
  86. -- IMPLEMENTATION
  87. function convertNBT(nbt)
  88.     local conv = {}
  89.     if (nbt == nil) then
  90.         return nil
  91.     elseif (nbt["type"] == "NBTTagCompound") or (nbt["type"] == "NBTTagList") then
  92.         for key, value in pairs(nbt["value"]) do
  93.             conv[key] = convertNBT(value)
  94.         end
  95.     else
  96.         conv = nbt["value"]
  97.     end
  98.     return conv
  99. end
  100.  
  101. function getItems(pipe)
  102.     pipe.getAvailableItems()
  103.     local event, result = os.pullEvent("available_items_return")
  104.     return result
  105. end
  106.  
  107. function inList(item)
  108.     for _, id in pairs(REQUEST_IDS) do
  109.         if item.id == id then
  110.             return true
  111.         end
  112.     end
  113.     return false
  114. end
  115.  
  116.  
  117. -- MAIN
  118. local pipe = peripheral.wrap(PIPE_SIDE)
  119. while true do
  120.     for i, result in pairs(getItems(pipe)) do
  121.         local iid, amount = unpack(result)
  122.         local item = {
  123.             id = pipe.getItemID(iid),
  124.             dmg = pipe.getItemDamage(iid),
  125.             nbt = convertNBT(pipe.getNBTTagCompound(iid))
  126.         }
  127.         if inList(item) then
  128.             pipe.makeRequest(iid, amount)
  129.             sleep(2)
  130.         end
  131.     end
  132.     sleep(INTERVAL)
  133. end
Add Comment
Please, Sign In to add comment