Advertisement
Guest User

startup

a guest
May 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.61 KB | None | 0 0
  1. local mon = peripheral.wrap("monitor_4")
  2. --local mon = peripheral.wrap("left")
  3. local rec = peripheral.wrap("back")
  4. local dt = peripheral.wrap("fluid_gate_0")
  5. version = 1.1
  6. max = 80
  7. min = 20
  8. local standard = 44
  9. local text = colors.lightBlue
  10. local normal = colors.white
  11. local rahmen = colors.gray
  12. activ = 0
  13. blink = 0
  14. tabelMax = 4
  15. tabel = 1
  16. nDT = 0
  17.  
  18. -- DNT
  19. --local Cap = max/100
  20. --local softCap = min/100
  21.  
  22. function alert()
  23.     if Deut <= 500 or Trit <= 500 then
  24.         rec.setInjectionRate(2)
  25.         rs.setOutput("top", true)
  26.         term.setTextColor(colors.red)
  27.     else
  28.         rs.setOutput("top", false)
  29.     end
  30. end
  31.    
  32. function reactor()
  33.  local Cap = max/100
  34.  local softCap = min/100
  35.  Trit = rec.getTritium()
  36.     Deut = rec.getDeuterium()
  37.     energy = rec.getEnergy()
  38.  energyMax = rec.getMaxEnergy()    
  39.     mon.clear()
  40.     term.redirect(mon)
  41.     term.setCursorPos(2,19)
  42.     term.setTextColor(colors.gray)
  43.     write("V"..version.." written by adreaner ©")
  44.     term.setTextColor(colors.white)
  45.     paintutils.drawBox(2,2,12,18,rahmen)
  46.     term.setCursorPos(4,7)
  47.     local posX, posY = term.getCursorPos()
  48.        
  49. -- Fuel
  50.     term.setBackgroundColor(colors.black)
  51.     term.setTextColor(colors.white)
  52.     mon.setCursorPos(4,2)
  53.     term.setTextColor(text)
  54.     write(" Fuel ")
  55.     term.setTextColor(normal)
  56.     local DeutF= 10-((Deut*100/1000)/10)
  57.     local TritF= 10-((Trit*100/1000)/10)
  58.     paintutils.drawFilledBox(4,4,6,16, colors.orange)
  59.     paintutils.drawFilledBox(4,4,6,4+DeutF, colors.lightGray)
  60.     paintutils.drawFilledBox(8,4,10,16, colors.lightBlue)
  61.     paintutils.drawFilledBox(8,4,10,4+TritF, colors.lightGray)
  62.     term.setBackgroundColor(colors.black)
  63. -- Fuel end
  64.    
  65. -- Energy Capacity
  66.     paintutils.drawBox(14,2,38,6, rahmen)
  67.     term.setCursorPos(16,2)
  68.     term.setBackgroundColor(colors.black)
  69.     term.setTextColor(text)
  70.     write(" Energy level ")
  71.     term.setTextColor(normal)
  72.     local EnergyF     = (energy*100/energyMax)/10
  73.     local energyRF    = math.floor(energy/2500,0.5)
  74.     local energyMaxRF = energyMax/2500
  75.     paintutils.drawFilledBox(16,4,36,4, colors.red)
  76.     paintutils.drawFilledBox(16,4,16+EnergyF*2,4, colors.lime)
  77.     if blink == 2 then
  78.         paintutils.drawBox(16+20*Cap,4,16+20*Cap,4, colors.orange)
  79.         paintutils.drawBox(16+20*softCap,4,16+20*softCap,4, colors.cyan)
  80.         blink = 0
  81.     else
  82.         blink = blink+1
  83.     end
  84.     term.setCursorPos(17,3)
  85.     term.setBackgroundColor(colors.black)
  86.     write(energyRF.."/"..energyMaxRF.." KRF")
  87.     term.setBackgroundColor(colors.black)
  88. -- Energy Capacity end
  89.  
  90. -- Info
  91. -- Production
  92.     paintutils.drawBox(14,8,38,13, rahmen)
  93.     term.setCursorPos(16,8)
  94.     term.setBackgroundColor(colors.black)
  95.     term.setTextColor(text)
  96.     write(" Info ")
  97.     term.setTextColor(normal)
  98.     term.setCursorPos(16,9)
  99.     local IsActiv = rec.isIgnited()
  100.     write("Status: ")
  101.     if IsActiv == true and nDT == 0 then
  102.         term.setTextColor(colors.lime)
  103.         write("Activ")
  104.     elseif IsActiv == true and nDT > 0 then
  105.         term.setTextColor(colors.purple)
  106.         write("Overclocked ")
  107.     else
  108.         term.setTextColor(colors.red)
  109.         write("Offline")
  110.     end
  111.     term.setTextColor(colors.white)
  112.     term.setCursorPos(16,11)
  113.     write("Energy in %:   ")
  114.     local EnergyPer = (math.floor(energy*1000/energyMax, 0.5))/10
  115.     write(EnergyPer)
  116.     term.setCursorPos(16,10)
  117.     write("Production: ")
  118.     local RFpT = (rec.getProducing()/250000)/10
  119.     if RFpT < 1 then
  120.         RFpT = (rec.getProducing()/250)/10
  121.         write(RFpT)
  122.         term.setTextColor(colors.orange)
  123.         term.setCursorPos(33,10)
  124.         write("KRF/T")
  125.     else
  126.         write(RFpT)
  127.         term.setTextColor(colors.yellow)
  128.         term.setCursorPos(32,10)
  129.         write(" MRF/T")
  130.     end
  131. -- Production end
  132.  
  133. -- Injection Rate
  134.     term.setCursorPos(16,12)
  135.     term.setTextColor(colors.white)
  136.     write("InjectionRate: ")
  137. -- Injection Rate end
  138. -- Info end
  139.    
  140. -- alert
  141.     paintutils.drawBox(14,15,38,18, rahmen)
  142.     term.setCursorPos(16,15)
  143.     term.setBackgroundColor(colors.black)
  144.     term.setTextColor(text)
  145.     write(" Alerts ")
  146.     term.setTextColor(normal)
  147.     if activ == 1 then
  148.         term.setCursorPos(16,16)
  149.         term.setTextColor(colors.orange)
  150.         write("Energy cap reached!")
  151.         term.setCursorPos(16,17)
  152.         write("Lowering Injection!")
  153.     end        
  154.     if Trit <= 500 then
  155.         paintutils.drawBox(15,16,37,17, colors.black)
  156.         term.setCursorPos(16,16)
  157.         rahmen = colors.red
  158.         term.setTextColor(colors.red)
  159.         write("Tritium LOW!")
  160.         term.setCursorPos(16,17)
  161.         write("LvL: "..Trit)
  162.     elseif Deut <= 500 then
  163.         paintutils.drawBox(15,16,37,17, colors.black)
  164.         term.setCursorPos(16,16)
  165.         rahmen = colors.red
  166.         term.setTextColor(colors.red)
  167.         write("Deuterium LOW!")
  168.         term.setCursorPos(16,17)
  169.         write("LvL: "..Deut)
  170.     else
  171.         rahmen = colors.gray
  172.     end
  173. -- alert off
  174.            
  175. -- Injection Hard Cap
  176.     term.setTextColor(colors.yellow)
  177.     if energy >= energyMax*Cap then
  178.             rec.setInjectionRate(4)
  179.             term.setTextColor(colors.orange)
  180.             activ = 1
  181.     elseif energy <= energyMax*softCap then
  182.         term.setTextColor(colors.green)
  183.         rec.setInjectionRate(standard)
  184.         activ = 0
  185.     end
  186.     if activ == 0 then
  187.         rec.setInjectionRate(standard)
  188.     end
  189. -- Injection Hard Cap end
  190.     term.setCursorPos(31,12)
  191.     write(rec.getInjectionRate())
  192.     if exit == 1 then
  193.         paintutils.drawBox(2,6,39,15, colors.white)
  194.         paintutils.drawFilledBox(3,7,38,14, colors.black)
  195.         term.setTextColor(colors.white)
  196.         term.setCursorPos(4,8)
  197.         --mon.setTextScale(0.5)
  198.         write("This will ")
  199.         term.setTextColor(colors.red)
  200.         write("shutdown ")
  201.         term.setTextColor(colors.white)
  202.         write("the Reactor!")
  203.         term.setCursorPos(4,9)
  204.         write("You need ")
  205.         term.setTextColor(colors.orange)
  206.         write("1x Hohlraum ")
  207.         term.setTextColor(colors.white)
  208.         write("loaded with")
  209.         term.setCursorPos(4,10)
  210.         term.setTextColor(colors.purple)
  211.         write("D-T fuel ")
  212.         term.setTextColor(colors.white)
  213.         write("to restart the Reactor!")
  214.         term.setCursorPos(4,11)
  215.         write("Continue?")
  216.         paintutils.drawBox(7,13,12,13, colors.red)
  217.         term.setCursorPos(9,13)
  218.         write("Yes")
  219.         paintutils.drawBox(29,13,34,13, colors.lime)
  220.         term.setCursorPos(31,13)
  221.         write("No!")
  222.         --mon.setTextScale(1)
  223.     end
  224.     paintutils.drawBox(40,17,49,18, colors.gray)
  225.     paintutils.drawBox(42,18,47,18, colors.black)
  226.     term.setCursorPos(41,17)
  227.     term.setTextColor(text)
  228.     write(" DTFuel ")
  229.     term.setTextColor(colors.purple)
  230.     term.setCursorPos(42,18)
  231.     if string.len(nDT) == 1 then
  232.         write("0")
  233.     end
  234.     write(nDT.."mb/t")
  235.     --term.setCursorPos(3,1-17)
  236.     --write("time")
  237.     --write(clock())
  238.     term.setBackgroundColor(colors.black)  
  239.     alert()        
  240.     --term.setCursorPos(31,12)
  241.     --write(rec.getInjectionRate())
  242.     sleep(0.5)
  243. end
  244.  
  245. function click()
  246.     local dtf = dt.getSignalLowFlow()
  247.     term.setTextColor(colors.white)
  248.     paintutils.drawBox(50,1,50,1, colors.red)
  249.     term.setCursorPos(50,1)
  250.     write("X")
  251.     paintutils.drawBox(40,2,49,15, rahmen)
  252.     term.setCursorPos(40,15)
  253.     write("<        >")
  254.     term.setCursorPos(42,2)
  255.     term.setBackgroundColor(colors.black)
  256.     term.setTextColor(text)
  257.     if tabel <= 0 then
  258.         tabel = 1
  259.     elseif tabel > tabelMax then
  260.         tabel = tabelMax
  261.     elseif tabel == 1 then
  262.         write("Inject")
  263.         term.setCursorPos(42,15)
  264.         write(" rate ")
  265.         term.setTextColor(normal)
  266.     elseif tabel == 2 then
  267.         write("Energy")
  268.         term.setCursorPos(42,15)
  269.         write(" min. ")
  270.     elseif tabel == 3 then
  271.         write("Energy")
  272.         term.setCursorPos(42,15)
  273.         write(" max. ")
  274.     elseif tabel == 4 then
  275.         write("DTFuel")
  276.         term.setCursorPos(42,15)
  277.         write(" inj. ")
  278.     end    
  279.     term.setTextColor(colors.white)
  280.    
  281.     paintutils.drawFilledBox(42,4,47,4, colors.lime)
  282.     term.setCursorPos(43,4)
  283.     write("+10")
  284.     paintutils.drawFilledBox(42,6,47,6, colors.green)
  285.     term.setCursorPos(43,6)
  286.     write(" +1")
  287.     paintutils.drawFilledBox(42,8,47,8, colors.lightBlue)
  288.     term.setCursorPos(43,8)
  289.     if tabel == 1 then
  290.         write(" =4")
  291.     elseif tabel == 2 or tabel == 3 then
  292.         write(" 50")
  293.     elseif tabel == 4 then
  294.         write(" =0")
  295.     end
  296.     paintutils.drawFilledBox(42,10,47,10,colors.orange)
  297.     term.setCursorPos(43,10)
  298.     write(" -1")
  299.     paintutils.drawFilledBox(42,12,47,12,colors.red)
  300.     term.setCursorPos(43,12)
  301.     write("-10")
  302.     paintutils.drawBox(41,14,48,14, rahmen)
  303.     term.setCursorPos(43,14)
  304.     term.setBackgroundColor(colors.black)
  305.     if tabel == 1 then
  306.         write(" "..standard.." ")
  307.     elseif tabel == 2 then
  308.         write(" "..min.."%")
  309.     elseif tabel == 3 then
  310.         write(" "..max.."%")
  311.     elseif tabel == 4 then
  312.         write(" "..dtf.." ")
  313.     end
  314.    
  315.     event, side, xPos, yPos = os.pullEvent("monitor_touch")
  316.     if xPos >= 42 and xPos <= 47 and yPos == 4 then
  317.         if tabel == 1 then
  318.             standard = standard+10
  319.         elseif tabel == 2 then
  320.             min = min+10
  321.         elseif tabel == 3 then
  322.             max = max+10
  323.         elseif tabel == 4 then
  324.             nDT = nDT+10
  325.         end
  326.     elseif xPos >= 42 and xPos <= 47 and yPos == 6 then
  327.         if tabel == 1 then
  328.             standard = standard+1
  329.         elseif tabel == 2 then
  330.             min = min+1
  331.         elseif tabel == 3 then
  332.             max = max+1
  333.         elseif tabel == 4 then
  334.             nDT = nDT+1
  335.         end
  336.     elseif xPos >= 42 and xPos <= 47 and yPos == 8 then
  337.         if tabel == 1 then
  338.             standard = 4
  339.         elseif tabel == 2 then
  340.             min=50
  341.         elseif tabel == 3 then
  342.             max=50
  343.         elseif tabel == 4 then
  344.             nDT=0
  345.         end
  346.     elseif xPos >= 42 and xPos <= 47 and yPos == 10 then
  347.         if tabel == 1 then
  348.             standard = standard-1
  349.         elseif tabel == 2 then
  350.             min = min-1
  351.         elseif tabel == 3 then
  352.             max = max-1
  353.         elseif tabel == 4 then
  354.             nDT = nDT-1
  355.         end
  356.     elseif xPos >= 42 and xPos <= 47 and yPos == 12 then
  357.         if tabel == 1 then
  358.             standard = standard-10
  359.         elseif tabel == 2 then
  360.             min = min-10
  361.         elseif tabel == 3 then
  362.             max = max-10
  363.         elseif tabel == 4 then
  364.             nDT = nDT-10
  365.         end
  366.     elseif xPos == 50 and yPos == 1 then
  367.         exit = 1
  368.     elseif xPos >= 7 and xPos <= 12 and yPos == 13 and exit == 1 then
  369.         exit = 0
  370.         rec.setInjectionRate(0)
  371.         sleep(0.5)
  372.         rec.setInjectionRate(standard)
  373.     elseif xPos >= 29 and xPos <= 34 and yPos == 13 and exit == 1 then
  374.         exit = 0
  375.     elseif xPos == 40 and yPos == 15 then
  376.         tabel = tabel-1
  377.         if tabel == 0 then
  378.             tabel = tabelMax
  379.         end
  380.     elseif xPos == 49 and yPos == 15 then
  381.         tabel = tabel+1
  382.         if tabel > tabelMax then
  383.             tabel = 1
  384.         end
  385.     end
  386.     if standard <= 1 then
  387.         standard = 2
  388.     end
  389.     if nDT < 0 then
  390.         nDT = 0
  391.     elseif nDT > 99 then
  392.         nDT = 99
  393.     end
  394.     dt.setSignalLowFlow(nDT)
  395.    
  396.     term.setBackgroundColor(colors.black)
  397.     sleep(0.5)
  398. end
  399.  
  400.  
  401. while true do
  402.     parallel.waitForAny(reactor, click)
  403. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement