Advertisement
Guest User

startup

a guest
Feb 23rd, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.72 KB | None | 0 0
  1. reactorA = peripheral.wrap("BigReactors-Reactor_17")
  2. reactorB = peripheral.wrap("BigReactors-Reactor_16")
  3. reactorC = peripheral.wrap("BigReactors-Reactor_18")
  4. reactorD = peripheral.wrap("BigReactors-Reactor_19")
  5. reactorE = peripheral.wrap("BigReactors-Reactor_20")
  6. reactorF = peripheral.wrap("BigReactors-Reactor_21")
  7. turbineA = peripheral.wrap("BigReactors-Turbine_8")
  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. monitor = peripheral.wrap("monitor_26")
  14. monitorB = peripheral.wrap("back")
  15.  
  16. monitor.setBackgroundColor(colors.white)
  17. monitorB.setBackgroundColor(colors.white)
  18. monitor.clear()
  19. monitorB.clear()
  20.  
  21. function topbar()
  22.   monitor.setCursorPos(1,1)
  23.   monitorB.setCursorPos(1,1)
  24.   monitor.setBackgroundColor(colors.black)
  25.   monitorB.setBackgroundColor(colors.black)
  26.   monitor.setTextColor(colors.white)
  27.   monitorB.setTextColor(colors.white)
  28.   monitor.write("Turbine-Reactor Control Interface                                                  ")
  29.   monitorB.write("Turbine-Reactor Status Interface                                                   ")
  30. end
  31.  
  32. function valint(x,y,name,val,valN,length,device)
  33.   val = math.floor(val*100)/100
  34.   device.setCursorPos(x,y)
  35.   device.setBackgroundColor(colors.lightGray)
  36.   for i = 0,length do
  37.     device.setCursorPos(x+i,y)
  38.     device.write(" ")
  39.   end
  40.   device.setCursorPos(x,y)
  41.   device.write(name..": ")
  42.   device.setCursorPos(x+(length/2),y)
  43.   device.write(val.." "..valN)
  44. end
  45.  
  46. function background(device)
  47.   x,y = device.getSize()
  48.   --print(x)
  49.   device.setTextColor(colors.black)
  50.   device.setBackgroundColor(colors.white)
  51.   for iy = 1,y do
  52.     for ix = 1,x do
  53.       device.setCursorPos(ix,iy)
  54.       device.write(".")
  55.     end
  56.   end
  57. end
  58.  
  59. function loadMenu()
  60.   monitor.setBackgroundColor(colors.black)
  61.   xm,ym = monitor.getSize()
  62.   for iy=0,ym do
  63.     for ix=0,10 do
  64.       monitor.setCursorPos((xm-10)+ix,iy)
  65.       monitor.write(" ")
  66.     end
  67.   end
  68.   monitor.setTextColor(colors.lightGray)
  69.   monitor.setCursorPos(xm-8,3)
  70.   monitor.write(" Blank >")
  71.   monitor.setCursorPos(xm-8,10)
  72.   monitor.write(" Blank >")
  73.   monitor.setCursorPos(xm-8,17)
  74.   monitor.write(" Blank >")
  75.   monitor.setCursorPos(xm-8,24)
  76.   monitor.write(" Blank >")
  77. end
  78.  
  79.  
  80. function getValues(reactor,turbine,num)
  81.     data = {
  82.     tempC = reactor.getFuelTemperature(),
  83.     tempM = 2000,
  84.     fuelC = reactor.getFuelAmount(),
  85.     fuelM = 20000,
  86.     enerC = turbine.getEnergyStored(),
  87.     enerM = 1000000,
  88.     fuelU = reactor.getFuelConsumedLastTick(),
  89.     fuelR = reactor.getFuelReactivity(),
  90.     enerP = turbine.getEnergyProducedLastTick(),
  91.     fuelW = reactor.getWasteAmount(),
  92.     rodsP = reactor.getControlRodLevel(0),
  93.     rodsM = 100,
  94.     hotfP = reactor.getHotFluidProducedLastTick(),
  95.     hotfC = reactor.getHotFluidAmount(),
  96.     hotfM = reactor.getHotFluidAmountMax(),
  97.     coolC = reactor.getCoolantAmount(),
  98.     coolM = reactor.getCoolantAmountMax(),
  99.     rotoS = turbine.getRotorSpeed()
  100.   }
  101. end
  102.  
  103. function indic(x,y,name,val,length,device)
  104.   device.setBackgroundColor(colors.lightGray)
  105.   device.setTextColor(colors.black)
  106.   for i=0,length do
  107.     device.setCursorPos(x+i,y)
  108.     device.write(" ")
  109.   end
  110.   device.setCursorPos(x+2,y)
  111.   device.write(name)
  112.   device.setCursorPos(x,y)
  113.   if val == true then
  114.     status = colors.green
  115.   elseif val == false then
  116.     status = colors.red
  117.   else
  118.     status = colors.orange
  119.   end
  120.   device.setBackgroundColor(status)
  121.   device.write(" ")
  122. end
  123.  
  124. function inp()
  125.   input = rs.getBundledInput("left")
  126.   --print(input)
  127.   if input >= 8 then
  128.     d = true
  129.     input = input - 8
  130.   else
  131.     d = false
  132.   end
  133.   if input >= 4 then
  134.     c = true
  135.     input = input - 4
  136.   else
  137.     c = false
  138.   end
  139.   if input >= 2 then
  140.     b = true
  141.     input = input - 2
  142.   else
  143.     b = false
  144.   end
  145.   if input >= 1 then
  146.     a = true
  147.   else
  148.     a = false
  149.   end
  150.   --print(a)
  151.   --print(b)
  152.   --print(c)
  153. end
  154.  
  155. function bar(x,y,name,valA,valB,length,disp,mult,col,device)
  156.   if disp == true or disp == "bvottom" then
  157.     if disp ~= true then
  158.       a = 2
  159.     else
  160.       a = 0
  161.     end
  162.     perc = math.floor((valA/valB)*100*100)/100
  163.     device.setCursorPos(x,y+a)
  164.     device.setBackgroundColor(colors.white)
  165.     device.setTextColor(colors.black)
  166.     for ix = 0,length-1 do
  167.       device.setCursorPos(x+ix,y+a)
  168.       device.write(" ")
  169.     end
  170.     device.setCursorPos(x,y)
  171.     device.write(name)
  172.     device.setCursorPos(x+length-6,y+a)
  173.     device.write(perc)
  174.     device.setCursorPos(x+length-1,y+a)
  175.     device.write("%")
  176.     if valA > valB then
  177.       valB = valA
  178.     end
  179.   end
  180.   if disp == true then
  181.     device.setBackgroundColor(colors.gray)
  182.     for i=0,length-1 do
  183.       device.setCursorPos(x+i,y+1)
  184.       device.write(" ")
  185.     end
  186.   end
  187.   im = (valA / valB) * length
  188.   device.setBackgroundColor(col)
  189.   for i=0,im-1 do
  190.     device.setCursorPos(x+i,y+1)
  191.     device.write(" ")
  192.   end
  193. end
  194.  
  195. function indicate(p,y)
  196.   if p == true then
  197.     monitor.setBackgroundColor(colors.green)
  198.   else
  199.     monitor.setBackgroundColor(colors.red)
  200.   end
  201.   monitor.setCursorPos(41,y)
  202.   monitor.write(" ")
  203. end
  204.  
  205. function turbineLayout(reactor,turbine,x,y)
  206.   getValues(reactor,turbine)
  207.   bar(x,y,"Fuel Amount",data.fuelC,data.fuelM,20,true,1,colors.yellow,monitorB)
  208.   bar(x,y+3,"Rotor Speed",data.rotoS,2000,20,true,1,colors.cyan,monitorB)
  209.   bar(x,y+6,"Energy Buffer",data.enerC,data.enerM,20,true,1,colors.red,monitorB)
  210. end
  211.  
  212. function blanky(x,y,length,height,color,device)
  213.   device.setBackgroundColor(color)
  214.   for iy = 0,height do
  215.     for i = 0,length do
  216.       device.setCursorPos(x+i,y+iy)
  217.       device.write(" ")
  218.     end
  219.   end
  220. end
  221.  
  222. background(monitorB)
  223. background(monitor)
  224. topbar()
  225.  
  226. while true do
  227.   getValues(reactorA,turbineA)
  228.   inp()
  229.   loadMenu()
  230.   turbineLayout(reactorA,turbineA,4,4)
  231.   turbineLayout(reactorB,turbineB,28,4)
  232.   turbineLayout(reactorC,turbineC,4,14)
  233.   turbineLayout(reactorD,turbineD,28,14)
  234.   turbineLayout(reactorE,turbineE,4,24)
  235.   turbineLayout(reactorF,turbineF,28,24)
  236.   blanky(6,7,22,18,colors.gray,monitor)
  237.   monitor.setTextColor(colors.white)
  238.   monitor.setBackgroundColor(colors.black)
  239.   monitor.setCursorPos(6,7)
  240.   monitor.write(" Reactor Power Status: ")
  241.   indic(7,9,"REACTOR A",reactorA.getActive(),20,monitor)
  242.   indic(7,12,"REACTOR B",reactorB.getActive(),20,monitor)
  243.   indic(7,15,"REACTOR C",reactorC.getActive(),20,monitor)
  244.   indic(7,18,"REACTOR D",reactorD.getActive(),20,monitor)
  245.   indic(7,21,"REACTOR E",reactorE.getActive(),20,monitor)
  246.   indic(7,24,"REACTOR F",reactorF.getActive(),20,monitor)
  247.   sleep(0.2)
  248. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement