Advertisement
meigrafd

ComputerCraft: AE2 Sorter

Aug 27th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. --[[
  2.  
  3.  For: ComputerCraft
  4.  
  5.   If the Nuclear Reactor overheats the Robot drops not only depleted Uran Rods into the Trash...
  6.  If your using Applied Energistics (like me) for Supporting the Robot you will have much used Rods after some Days
  7.  which will blow you storages...
  8.  And here comes this Script in place:
  9.  Extract all used Uran Rods from AE System and split them into a Chest. This Chest can than be linked to another AE or whatever..
  10.  
  11.  Setup:
  12.  - Place an ME_Interface_Block to a Computer.
  13.  - Connect the ME_Interface with your AE Network and to another side of the ME_Interface place a Chest.
  14.  
  15. --]]
  16.  
  17.  
  18. -- Direction from ME_Interface to Chest. Only valid: north, south, west, east, up, down
  19. directionChest = "NORTH"
  20.  
  21. -- Side of ME_Interface. Only valid sides: left, right, back, front, up, bottom
  22. meInterfaceSide = "back"
  23.  
  24. -- Export all Items with a minimum or equal damage value of ...
  25. local minDamage = 10
  26.  
  27. local CheckEvery = 15  -- sec.
  28.  
  29.  
  30. --[[ Internal values - DONT change! ]]
  31.  
  32.  
  33. local meInterface = peripheral.wrap(meInterfaceSide)
  34.  
  35. local version = 0.1
  36. local Count = 0
  37.  
  38. function exportDamagedItems()
  39.     for number,item in pairs(itemList) do
  40.         local ID = item.fingerprint.id
  41.         local DMG = item.fingerprint.dmg
  42.         if (DMG >= minDamage) then
  43.             Count = Count + 1
  44.             meInterface.exportItem(item.fingerprint, directionChest, 1, 0)
  45.             print("("..Count..") Exported "..ID.." with dmg: "..DMG)
  46.         end
  47.     end
  48. end
  49.  
  50.  
  51.  
  52. ---[[ Main Program ]]
  53.  
  54.  
  55. while true do
  56.     itemList = meInterface.getAvailableItems()
  57.     exportDamagedItems()
  58.     os.sleep(CheckEvery)
  59. end
  60.  
  61.  
  62. --
  63. -- EOF
  64. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement