Advertisement
Guest User

startup

a guest
Feb 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.97 KB | None | 0 0
  1. local setup = { 0, 1, 0, 1, 0, 1, 0, 0, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 2 }
  2.  
  3. local inventory = nil
  4. local producing = false
  5. local refuelReactor = true
  6. local storageSide = "south"
  7. local recycleSide = "north"
  8.  
  9. local reactor = peripheral.wrap("top")
  10. local storage = peripheral.wrap("tileinterface_3")
  11. local recycler = peripheral.wrap("tileinterface_4")
  12.  
  13. local lzhF = { id = "IC2:item.reactorCondensatorLap", dmg = 0, }
  14. local uranF = { id = "IC2:item.reactorUraniumQuad", dmg = 0, }
  15. local overF = { id = "IC2:item.reactorVentGold", dmg = 0, }
  16.  
  17.  
  18. local function refuel()
  19.  
  20.     if refuelReactor == true then
  21.         refuelReactor = false
  22.         rs.setOutput("bottom", true)
  23.         rs.setOutput("front", false)
  24.        
  25.        
  26.         -- Recycle All Old Components
  27.         if inventory ~= nil then
  28.        
  29.             for o = 1, 54 do
  30.                     recycler.pullItem(recycleSide, o, 1, 1)
  31.             end
  32.            
  33.         end
  34.        
  35.         -- Export Items Into Reactor In Co-Ordinated Slots
  36.         for w = 1, 54 do
  37.             term.clear()
  38.             term.setCursorPos(1,1)
  39.             print("Refueling Now! " .. w)  
  40.             if setup[w] == 0 then
  41.                 storage.exportItem(lzhF, storageSide, 1, w)
  42.             elseif setup[w] == 1 then
  43.                 storage.exportItem(uranF, storageSide, 1, w)
  44.             elseif setup[w] == 2 then
  45.                 storage.exportItem(overF, storageSide, 1, w)
  46.             end
  47.            
  48.         end
  49.    
  50.     end
  51.  
  52.     rs.setOutput("bottom", false)
  53.    
  54.    
  55.     for q = 241, 0, -1 do
  56.         term.clear()
  57.         term.setCursorPos(1,1)
  58.         print("Waming up cooling drive! " .. q)
  59.         sleep(1.1)
  60.     end
  61.    
  62.     rs.setOutput("front", true)
  63.    
  64. end
  65.  
  66. refuel()
  67.  
  68. while true do
  69.     term.clear()
  70.     term.setCursorPos(1,1)
  71.     producing = rs.getInput("back")
  72.  
  73.     -- Interface
  74.     print("Running: " .. tostring(reactor.isActive()) .. "\n")
  75.    
  76.     print("Heat: " .. reactor.getHeat())
  77.     print("ProducingEU: " .. tostring(producing))
  78.     -- Interface
  79.    
  80.     -- Functionality
  81.    
  82.    
  83.     if producing == true then
  84.         refuelReactor = true
  85.     elseif producing == false and refuelReactor == true then
  86.         refuel()
  87.     end
  88.    
  89.     if reactor.isActive() and reactor.getHeat() >= 100 then -- Reactor is Running and Has OverHeated
  90.    
  91.         rs.setOutput("front", false) -- Stop Reactor
  92.         for y = 1, 54 do
  93.             recycler.pullItem(recycleSide, y, 1, 1) -- Pull All Items From Within The Reactor
  94.         end
  95.        
  96.     elseif reactor.isActive() and reactor.getHeat() < 100 then -- Reactor is Running and Hasn't OverHeated
  97.        
  98.         inventory = reactor.getAllStacks()
  99.         rs.setOutput("front", true)  
  100.    
  101.         if inventory ~= nil then
  102.        
  103.             for i = 1, 54 do
  104.                
  105.                 if inventory[i] ~= nil then
  106.                
  107.                     if inventory[i].id == uranF.id and inventory[i].dmg >= 8000 then
  108.                         if setup[i] == 1 then
  109.                             recycler.pullItem(recycleSide, i, 1, 1)
  110.                             storage.exportItem(lzhF, storageSide, 1, i)
  111.                         end
  112.                     end
  113.                    
  114.                 elseif inventory[i] == nil and setup[i] == 1 then
  115.                
  116.                     storage.exportItem(uranF, storageSide, 1, i)
  117.                    
  118.                 end
  119.             end
  120.         end
  121.     end
  122.     -- Functionality
  123.     os.queueEvent("fakeEvent")
  124.     os.pullEvent()
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement