Advertisement
Guest User

test3

a guest
Jun 3rd, 2016
1,094
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.73 KB | None | 0 0
  1. -- Reactor Search
  2. local reactor = peripheral.find("BigReactors-Reactor")
  3. if reactor then
  4.  print("Reaktor gefunden")
  5. end
  6.  
  7. -- Create Variables
  8. --local targetspeed = 1845
  9. --local targetspeed = 2860
  10. --local targetspeed = 5480
  11. local targetspeed = 6280
  12. --local targetspeed = 16280
  13. local speeddelay1 = 10
  14. local speeddelay2 = 100
  15. local reactorsleep = .1
  16. local turbinesleep = 0
  17. local turbinesetupsleep = .1
  18. local progsleep1 = 1
  19. local progsleep2 = .1
  20. local active = 0
  21. local count = 0
  22. local monside = "right"
  23. local turbine = peripheral.find("BigReactors-Turbine")
  24.  
  25.  
  26.  
  27. mon = peripheral.wrap(monside)
  28. mon.clear()
  29. --term.redirect(mon)
  30.  
  31. --Setup Turbines
  32. if turbine then
  33.  print("Turbinen gefunden")
  34.  local periList = peripheral.getNames()
  35.  for i = 1, #periList do
  36.   if string.find(peripheral.getType(periList[i]), "Turbine") then
  37.    local aTurbine = peripheral.wrap(periList[i])
  38.    count = count +1
  39.    print(periList[i], ": ", aTurbine.getActive())
  40.    active = active +1
  41.    aTurbine.setActive(true)    aTurbine.setInductorEngaged(false)
  42.    sleep(turbinesetupsleep)
  43.    aTurbine.setInductorEngaged(true)
  44.    --aTurbine.setVentNone()
  45.    aTurbine.setVentOverflow()
  46.     aTurbine.setFluidFlowRateMax(2000)  
  47.   end
  48.  end
  49.  print(#periList, " Gerte")
  50.  print(active, " aktive Turbinen")
  51. end
  52. sleep(progsleep1)
  53.  
  54.  
  55.  
  56. -- Get Ready
  57. local turbines = active
  58. local steam = turbines *2000
  59. reactor.setActive(true)
  60. reactor.setAllControlRodLevels(50)
  61.  
  62.  
  63. -- Steuerung
  64. while true do
  65.  
  66.  -- Reactor control
  67.  if reactor.getHotFluidProducedLastTick() > steam - 100 then
  68.   level = reactor.getControlRodLevel(1)
  69.    reactor.setAllControlRodLevels(level +1)
  70.    print("+1")
  71.    local turnon = "+1"
  72. --     mon.setCursorPos(5,6)
  73. --     mon.write("+1")
  74.    local a = 5
  75.    local b = "false"
  76.    while a > 0 do
  77.     if reactor.getHotFluidProducedLastTick() < steam then
  78.      b = "true"
  79.      if b == "true" then
  80.       level = reactor.getControlRodLevel(1)
  81.       reactor.setAllControlRodLevels(level -1)
  82.       b = "false"
  83.      end
  84.     end
  85.     a = a -1
  86.    end
  87.  else
  88.   if reactor.getHotFluidProducedLastTick() < steam then
  89.    if reactor.getControlRodLevel(1) > 1 then
  90.     if reactor.getHotFluidProducedLastTick() < steam then
  91.      level = reactor.getControlRodLevel(1)
  92.      reactor.setAllControlRodLevels(level -1)
  93.      print("-1")
  94.      local turnon = "-1"
  95. --       mon.setCursorPos(5,6)
  96. --       mon.write("-1")
  97.      sleep(reactorsleep)
  98.      periList = peripheral.getNames()
  99.     end
  100.    end
  101.   end
  102.  end
  103.  
  104.  
  105.  -- turbine control
  106.  local periList = peripheral.getNames()
  107.  for i = 1, #periList do
  108.   if string.find(periList[i], "Turbine") then
  109.    local aTurbine = peripheral.wrap(periList[i])
  110.    if aTurbine.getRotorSpeed() < (targetspeed - speeddelay1) then
  111.     aTurbine.setInductorEngaged(false)
  112.    end
  113.   end
  114.  end
  115.  sleep(turbinesleep)
  116.  local periList = peripheral.getNames()
  117.  for i = 1, #periList do
  118.   if string.find(periList[i], "Turbine") then
  119.    local aTurbine = peripheral.wrap(periList[i])
  120.    if aTurbine.getRotorSpeed() < targetspeed and aTurbine.getActive() == false then
  121.     aTurbine.setActive(true)
  122.     steam = steam +2000
  123.    else
  124.     if aTurbine.getRotorSpeed() > targetspeed and aTurbine.getActive() == true then
  125.      aTurbine.setActive(false)
  126.      steam = steam -2000
  127.     end
  128.    end
  129.    if aTurbine.getEnergyStored() < 100 then
  130.     if aTurbine.getRotorSpeed() > (targetspeed - speeddelay2) then
  131.      aTurbine.setInductorEngaged(true)
  132.     end
  133.    end
  134.    if aTurbine.getEnergyStored() > 100 and aTurbine.getFluidFlowRateMax() >= 2000 then
  135.     aTurbine.setFluidFlowRateMax(50)
  136.     steam = steam -1950
  137.    end
  138.      if aTurbine.getEnergyStored() < 100 and aTurbine.getFluidFlowRateMax() <= 50 then
  139.        aTurbine.setFluidFlowRateMax(2000)
  140.        steam = steam +1950
  141.       end
  142.   end
  143.  end
  144.  
  145.  sleep(progsleep2)
  146.  
  147.  
  148.  -- print
  149.  shell.run("clear")
  150.  print("ControlRodLevel: ", reactor.getControlRodLevel(1))
  151.    mon.setCursorPos(1,1)
  152.    mon.write("Control Rod Level: ")
  153.    mon.setCursorPos(20,1)
  154.    mon.write(reactor.getControlRodLevel(1))
  155.  print("       SteamOut: ", reactor.getHotFluidProducedLastTick(), "/", steam)
  156.    mon.setCursorPos(7,2)
  157.    mon.write("Steam Out:        /")
  158.    mon.setCursorPos(18,2)
  159.    mon.write(reactor.getHotFluidProducedLastTick())
  160.    mon.setCursorPos(26,2)
  161.    mon.write(steam)
  162.  print("       Turbinen: ", active, "/", count)
  163.    mon.setCursorPos(7,3)
  164.    mon.write("Turbines:     /")
  165.    mon.setCursorPos(17,3)
  166.    mon.write(active)
  167.    mon.setCursorPos(22,3)
  168.    mon.write(count)
  169.  print("       Target Speed:  ", targetspeed)
  170.    mon.setCursorPos(7,4)
  171.    mon.write("Target Speed: ")
  172.    mon.setCursorPos(21,4)
  173.    mon.write(targetspeed)
  174.  --write turn on  
  175.    mon.setCursorPos(5,6)
  176.    mon.write(turnon)
  177.    
  178. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement