Advertisement
flu047

Untitled

Feb 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. local turbine
  2. local reactor
  3. local restore = false
  4.  
  5. function reactorSearch()
  6.    local names = peripheral.getNames()
  7.    local i, name
  8.    for i, name in pairs(names) do
  9.       if peripheral.getType(name) == "BigReactors-Reactor" then
  10.          return peripheral.wrap(name)
  11.       else
  12.          --return null
  13.       end
  14.    end
  15. end
  16.  
  17. function turbineSearch()
  18.    local names = peripheral.getNames()
  19.    local i, name
  20.    for i, name in pairs(names) do
  21.       if peripheral.getType(name) == "BigReactors-Turbine" then
  22.          return peripheral.wrap(name)
  23.       else
  24.          --return null
  25.       end
  26.    end
  27. end
  28.  
  29. sleep(1)
  30.  
  31. turbine = turbineSearch()
  32. reactor = reactorSearch()
  33.  
  34. while true do
  35.     speed = turbine.getRotorSpeed()
  36.     reactorActive = reactor.getActive()
  37.  
  38.     if reactorActive == false and speed > 1750 and speed < 1800 then
  39.         turbine.setInductorEngaged(false)
  40.         turbine.setActive(false)
  41.     elseif speed < 1750 then
  42.         restore = true
  43.         turbine.setInductorEngaged(false)
  44.         turbine.setActive(true)
  45.         reactor.setActive(true)
  46.     elseif restore == true and speed > 1795 and speed < 1805 then
  47.         restore = false
  48.         turbine.setActive(false)
  49.         reactor.setActive(false)
  50.     end
  51.  
  52.     if reactorActive == true and restore == false then
  53.         turbine.setActive(true)
  54.         if speed > 1850 then
  55.             -- slow the turbine down, generate RF
  56.             turbine.setInductorEngaged(true)
  57.         end
  58.  
  59.         if speed < 1820 then
  60.             -- disengage rotors so they spin up again
  61.             turbine.setInductorEngaged(false)
  62.         end
  63.     end
  64.  
  65.     sleep(1)
  66.  
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement