Advertisement
DeBrates

CAReactor v4.0 | OpenComputers/Big Reactors Control Terminal

Jun 25th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.47 KB | None | 0 0
  1. --CAReactor by DeBrates(OpenComputers Port)
  2. --v4.0
  3. --Activate/De-Activate Button
  4. --Rod Controller (+-10%)
  5. --Dynamic Statistics
  6. --2 Tick(0.1s) RefreshRate
  7. --56x18 Monitor Size
  8. --Re-Wrap Your Peripherals/Components if Neccessary!
  9.  
  10. local component = require("component")
  11. local event = require("event")
  12. local colors = { blue = 0x4286F4, purple = 0xB673d6, red = 0xC14141, green = 0xDA841,
  13.   black = 0x000000, white = 0xFFFFFF, grey = 0x47494C, lightGrey = 0xBBBBBB, lime = 0x7DFF86,
  14.   warn = 0xFFD23D}
  15.  
  16. local r = component.br_reactor
  17. local mon = component.gpu
  18.  
  19.  
  20. mon.setResolution(56,18)
  21. --mon.setResolution(150,40)
  22. local w, h = mon.getResolution()
  23. mon.setBackground(colors.black)
  24.  
  25. while true do
  26.   local reactorOnline = r.getActive()  --Boolean
  27.   local energyProduction = r.getEnergyProducedLastTick()  --RF/t
  28.   local energyStored = r.getEnergyStored()   --RF
  29.   local fuelTemp = r.getFuelTemperature()    --C
  30.   local caseTemp = r.getCasingTemperature()  --C
  31.   local fuelAmount = r.getFuelAmount()       --mB
  32.   local wasteAmount = r.getWasteAmount()     --mB
  33.   local fuelReact = r.getFuelReactivity()    --%
  34.   local rodLevel = r.getControlRodLevel(0)   --%
  35.   local fuelCons = r.getFuelConsumedLastTick() --mB
  36.  
  37.   mon.fill(1,1,w,h," ")
  38.  
  39.   --Reactor Online
  40.   mon.setForeground(colors.white)
  41.   mon.set(1,1, "Active: ")
  42.   if reactorOnline then
  43.     mon.setForeground(colors.lime)
  44.   else
  45.     mon.setForeground(colors.red)
  46.   end      
  47.   if reactorOnline then
  48.     mon.set(9,1,"True")
  49.   else
  50.     mon.set(9,1,"False")
  51.   end    
  52.  
  53.   --RF/t Production
  54.   mon.setForeground(colors.white)
  55.   mon.set(1,2,"RF/t: ")
  56.   if energyProduction == 0 then
  57.     mon.setForeground(colors.red)  
  58.   elseif energyProduction <= 199 then
  59.     mon.setForeground(colors.warn)
  60.   else  
  61.     mon.setForeground(colors.lime)
  62.   end  
  63.   mon.set(7,2, math.ceil(energyProduction).." RF/t")    
  64.  
  65.   --Energy Stored
  66.   --mon.setCursor(1,3)
  67.   mon.setForeground(colors.white)
  68.   mon.set(1,3,"Energy Stored: ")
  69.   if energyStored < 1000000 then
  70.     mon.setForeground(colors.red)
  71.   else
  72.     mon.setForeground(colors.lime)
  73.   end  
  74.   mon.set(16,3, math.ceil(energyStored).." RF")
  75.  
  76.   --Fuel Temp
  77.   --mon.setCursor(1,4)
  78.   mon.setForeground(colors.white)
  79.   mon.set(1,4, "Fuel Temp: ")
  80.   mon.setForeground(colors.lime)
  81.   mon.set(12,4, math.ceil(fuelTemp).." C")
  82.  
  83.   --Case Temp
  84.   --mon.setCursor(1,5)
  85.   mon.setForeground(colors.white)
  86.   mon.set(1,5, "Case Temp: ")
  87.   mon.setForeground(colors.lime)
  88.   mon.set(12,5, math.ceil(caseTemp).." C")
  89.  
  90.   --Fuel Reactivity
  91.   --mon.setCursor(1,6)
  92.   mon.setForeground(colors.white)
  93.   mon.set(1,6, "Fuel React: ")
  94.   mon.setForeground(colors.lime)
  95.   mon.set(13,6, math.ceil(fuelReact).."%")
  96.  
  97.   --Fuel Amount
  98.   --mon.setCursor(1,7)
  99.   mon.setForeground(colors.white)
  100.   mon.set(1,7, "Fuel: ")
  101.   mon.setForeground(colors.lime)
  102.   mon.set(6,7, math.ceil(fuelAmount).." mB")
  103.  
  104.   --Fuel Consumption
  105.   --mon.setCursor(1,8)
  106.   mon.setForeground(colors.white)
  107.   mon.set(1,8, "Fuel Use: ")
  108.   mon.setForeground(colors.lime)
  109.   if fuelCons > 0 then
  110.     mon.set(11,8, "~")
  111.   end
  112.   mon.set(12,8, math.ceil(fuelCons * 100 / 10).." mB/t")
  113.  
  114.   --Waste Amount
  115.   --mon.setCursor(1,9)
  116.   mon.setForeground(colors.white)
  117.   mon.set(1,9, "Waste: ")
  118.  
  119.   if wasteAmount >= 899 then
  120.     mon.setForeground(colors.warn)
  121.   else
  122.     mon.setForeground(colors.lime)
  123.   end  
  124.   mon.set(8,9, math.ceil(wasteAmount).." mB")
  125.          
  126.   --Activation Button Display
  127.   if reactorOnline then
  128.     mon.setForeground(colors.red)
  129.   else
  130.     mon.setForeground(colors.lime)
  131.   end  
  132.   if reactorOnline then
  133.     mon.set(w-10,1, "De-Activate")
  134.   else
  135.     mon.set(w-7,1, "Activate")
  136.   end    
  137.  
  138.   --Rod Controller Display
  139.   --mon.setCursor(24,7)
  140.   mon.setForeground(colors.white)
  141.   mon.set(w-4,7, "Rods")
  142.   if rodLevel == 0 then
  143.     --mon.setCursor(25,8)
  144.     mon.set(w-4,8, rodLevel.."%")
  145.   else
  146.     --mon.setCursor(24,8)
  147.     mon.set(w-4,8, rodLevel.."%")
  148.   end  
  149.  
  150.   --mon.setCursor(22,8)
  151.   mon.set(w-6,8, "<")
  152.   --mon.setCursor(29,8)
  153.   mon.set(w,8, ">")
  154.  
  155.   function blank()
  156.  
  157.   end  
  158.  
  159.   --Button Timers
  160.   local name, _, x, y = event.pull(0.1, "touch")
  161.   if name then
  162.     if y == 1 and x > w-11 and reactorOnline then
  163.       r.setActive(false)
  164.     elseif y == 1 and x > w-8 then
  165.       r.setActive(true)
  166.     elseif y == 8 and x == w-6 then
  167.       r.setAllControlRodLevels(rodLevel - 10)
  168.     elseif y == 8 and x == w then
  169.       r.setAllControlRodLevels(rodLevel + 10)
  170.     end
  171.   end
  172. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement