Advertisement
meigrafd

OpenComputers: AE2 Sorter

Aug 18th, 2015
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.86 KB | None | 0 0
  1. --[[
  2.  
  3.  If the Nuclear Reactor overheats the Robot drops not only depleted Uran Rods into the Trash...
  4.  If your using Applied Energistics (like me) for Supporting the Robot you will have much such Rods after some Days
  5.  which will blow you storages...
  6.  And here comes this Script in place:
  7.  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..
  8.  
  9.  Setup:
  10.  - Connect an ME_Interface to an OC Adapter.
  11.  - Put the biggest Database-Upgrade (81 entries) into the Adapter.
  12.  - Connect the Adapter with a Cable to a Computer.
  13.  
  14.  Alternative you can put the Adapter directly to the ME_Controller..but than you have to change the Script...
  15.  - Put an Adapter in front of the ME_Controller. (directly to it)
  16.  - Connect the Adapter with a Cable to the Computer.
  17.  - You need to change the meInterfaceBus to meControllerBus lines as well as 'getAvailableItems()' to 'getItemsInNetwork()' ...
  18.  
  19.  
  20.  
  21. http://oc.cil.li/index.php?/topic/616-applied-energistics-2-using-oc-as-an-advanced-importexport-system/?hl=applied
  22. http://oc.cil.li/index.php?/topic/411-extracting-items-from-me-network-applied-energetics/
  23. http://oc.cil.li/index.php?/topic/481-ae-item-management-puzzle-whats-the-best-way-to-do-this/?hl=database
  24.  
  25. --]]
  26.  
  27.  
  28. --[[ Internal values - DONT change! ]]
  29.  
  30.  
  31. local component = require('component')
  32. local side = require('sides')
  33. local string = require('string')
  34. local meExportBus = component.getPrimary('me_exportbus')
  35. --local meExportBus = component.proxy(component.list("me_exportbus")())
  36. --local meExportBus = component.me_exportbus
  37. local meInterfaceBus = component.getPrimary('me_interface')
  38. --local meController = component.getPrimary('me_controller')
  39. local db = component.database
  40. --local dbAddress = db.address
  41. --local dbAddress = false
  42. --for k,_ in component.list('database') do dbAddress = k break end
  43. --dbInit = false
  44.  
  45. local version = 0.1
  46.  
  47.  
  48. ---[[ CONFIG - START ]]
  49.  
  50.  
  51.  
  52.  
  53. ---[[ CONFIG - END ]]
  54.  
  55.  
  56. function stringMatch(text, find)
  57.     if string.find(string.lower(text), string.lower(find)) then
  58.         return true
  59.     else
  60.         return false
  61.     end
  62. end
  63.  
  64.  
  65. --[[
  66. function init_db()
  67.     -- init database with all items?
  68.     if (dbInit == false) then
  69.         draw_text_term(1, linecount+1, 'Initialize Database!')
  70.         for i=1, #RequiredReactorInventory do
  71.             local Added = false
  72.             while (Added == false) do
  73.                 if (ic.store(side.front, i, dbAddress, i) == true) then
  74.                     Added = true
  75.                 end
  76.             end
  77.         end
  78.         dbInit = true
  79.     end
  80. end
  81.  
  82. for i = 0, 4 do
  83.     print("--------- Run " .. i .. " Start ---------\n")
  84.     print("Set Config: ",exBus.setExportConfiguration(busSide, 1, db.address, i+1))
  85.  
  86.     config = exBus.getExportConfiguration(busSide, 1)
  87.     print("\n!! Export Bus Config Start !!\n")
  88.     for k,v in pairs(config) do
  89.         print(k,v)
  90.     end
  91.     print("\n!! Export Bus Config End !!\n")
  92.  
  93.     print("Try Export: ",exBus.exportIntoSlot(busSide,i+1), "\n") -- try export an item
  94. end
  95.  
  96. exBus.setExportConfiguration(0) --clear the config
  97.  
  98. --]]
  99.  
  100.  
  101.  
  102. local exportBusSide
  103. for i = 0, 5 do
  104.     if select(2, meExportBus.getConfiguration(i)) ~= "no export bus" then
  105.         exportBusSide = i
  106.         break
  107.     end
  108. end
  109.  
  110. local entryNum = {}
  111. for i = 1, 81 do
  112.     local item = db.get(i)
  113.     if item then entryNum[item.name] = i end
  114. end
  115.  
  116.  
  117. local itemList = meInterfaceBus.getAvailableItems()
  118.  
  119. for k, v in pairs(itemList) do
  120.     if (v.fingerprint) then
  121.         for key,value in (v.fingerprint) do
  122.             if (stringMatch(key.id, "reactoruranium")) then
  123.                 print(key.id, key.value)
  124.             end
  125.         end
  126.     end
  127. end
  128. --meExportBus.setConfiguration(exportBusSide, 1, db.address, entryNum[v.name])
  129. --meExportBus.exportIntoSlot(exportBusSide, 1)
  130.  
  131.  
  132.  
  133.  
  134. --
  135. -- EOF
  136. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement