Advertisement
Guest User

startup

a guest
Feb 23rd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.22 KB | None | 0 0
  1. reactorA = peripheral.wrap("BigReactors-Reactor_16")
  2. turbineA = peripheral.wrap("BigReactors-Turbine_8")
  3. reactorB = peripheral.wrap("BigReactors-Reactor_17")
  4. reactorC = peripheral.wrap("BigReactors-Reactor_18")
  5. reactorD = peripheral.wrap("BigReactors-Reactor_19")
  6. reactorE = peripheral.wrap("BigReactors-Reactor_20")
  7. reactorF = peripheral.wrap("BigReactors-Reactor_21")
  8. turbineB = peripheral.wrap("BigReactors-Turbine_7")
  9. turbineC = peripheral.wrap("BigReactors-Turbine_9")
  10. turbineD = peripheral.wrap("BigReactors-Turbine_10")
  11. turbineE = peripheral.wrap("BigReactors-Turbine_11")
  12. turbineF = peripheral.wrap("BigReactors-Turbine_12")
  13.  
  14. me = peripheral.wrap("tilecontroller_0")
  15. --reactor.setAllControlRodLevels(60)
  16. ad = false
  17.  
  18. function inp()
  19.   --32768, 128, 1, 2048
  20.   input = rs.getBundledInput("left")
  21.   --if input ~= 0 then
  22.     --print(input)
  23.   --end
  24.   if input >= 32768 then
  25.     a = true
  26.     input = input - 32768
  27.   else
  28.     a = false
  29.   end
  30.   --if input >= 2048 then
  31.     --d = true
  32.     --input = input - 2048
  33.   --else
  34.     --d = true
  35.   --end
  36.   if input >= 128 then
  37.     b = true
  38.     input = input - 128
  39.   else
  40.     b = false
  41.   end
  42.   if input >= 1 then
  43.     c = true
  44.   else
  45.     c = false
  46.   end
  47. end
  48.  
  49. function check()
  50.   print(input)
  51.   print(a)
  52.   print(b)
  53.   print(c)
  54. end
  55.  
  56. function relay()
  57.   t = 0
  58.   if a == true then
  59.     t = t + 1
  60.   end
  61.   if b == true then
  62.     t = t + 2
  63.   end
  64.   if c == true then
  65.     t = t + 4
  66.   end
  67.   --if d == true then
  68.     --t = t + 8
  69.   --end
  70.   print("out: "..t)
  71.   rs.setBundledOutput("right",t)
  72. end
  73.  
  74.  
  75.    
  76. function autoAdjust(button,reactor)
  77.   if button == true and state ~= false then
  78.     --if reactor.getEnergyStored() < 8000000 then
  79.     if reactor.getHotFluidAmount() < 6500 and reactor.getCoolantAmount() > 3000 then
  80.       reactor.setActive(true)
  81.       ad = true
  82.     else
  83.       reactor.setActive(false)
  84.       ad = false
  85.     end
  86.     --if reactor.getFuelTemperature() < 1600 then
  87.     --  reactor.setActive(true)
  88.     --end
  89.   end
  90. end
  91.  
  92. function turbAdjust(button,turbine)
  93.   if button == true then
  94.     if turbine.getRotorSpeed() > 1850 then
  95.       turbine.setActive(false)
  96.     elseif turbine.getRotorSpeed() < 1800 then
  97.       turbine.setActive(true)
  98.     end
  99.     if turbine.getRotorSpeed() < 1800 and turbine.getRotorSpeed() > 220 then
  100.       turbine.setInductorEngaged(false)
  101.     else
  102.       turbine.setInductorEngaged(true)
  103.     end
  104.     if turbine.getEnergyStored() > 980000 then
  105.       turbine.setInductorEngaged(false)
  106.     end
  107.   end
  108. end
  109.  
  110.  
  111. function power(button,reactor)
  112.   if button == true and state ~= true then
  113.     reactor.setActive(true)
  114.     state = true
  115.   elseif button == false and state ~= false then
  116.     reactor.setActive(false)
  117.     state = false
  118.   end
  119. end
  120.  
  121.  
  122. while true do
  123.   inp()
  124.   check()
  125.   relay()
  126.   autoAdjust(b,reactorA)
  127.   autoAdjust(b,reactorB)
  128.   autoAdjust(b,reactorC)
  129.   autoAdjust(b,reactorD)
  130.   autoAdjust(b,reactorE)
  131.   autoAdjust(b,reactorF)
  132.   turbAdjust(c,turbineA)
  133.   turbAdjust(c,turbineB)
  134.   turbAdjust(c,turbineC)
  135.   turbAdjust(c,turbineD)
  136.   turbAdjust(c,turbineE)
  137.   turbAdjust(c,turbineF)
  138.   power(a,reactorA)
  139.   power(a,reactorB)
  140.   power(a,reactorC)
  141.   power(a,reactorD)
  142.   power(a,reactorE)
  143.   power(a,reactorF)
  144.   sleep(0.2)
  145. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement