DeBrates

CAReactor A1.0 - ComputerCraft/BigReactors Control

Jan 20th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.16 KB | None | 0 0
  1. --CAReactor by DeBrates
  2. --Activate/De-Activate Button
  3. --Rod Controller (+-10%)
  4. --Dynamic Statistics
  5. --1 Second RefreshRate
  6. --Or Manual Refresh on Touch
  7. --3x2 Monitor Size
  8. --Re-Wrap Your Peripherals if Necessary! (Wired Modem)
  9.  
  10. while true do
  11.   local r = peripheral.wrap("BigReactors-Reactor_0")
  12.   local mon = peripheral.wrap("monitor_0")
  13.   local reactorOnline = r.getActive()  --Boolean
  14.   local energyProduction = r.getEnergyProducedLastTick()  --RF/t
  15.   local energyStored = r.getEnergyStored()   --RF
  16.   local fuelTemp = r.getFuelTemperature()    --C
  17.   local caseTemp = r.getCasingTemperature()  --C
  18.   local fuelAmount = r.getFuelAmount()       --mB
  19.   local wasteAmount = r.getWasteAmount()     --mB
  20.   local fuelReact = r.getFuelReactivity()    --%
  21.   local rodLevel = r.getControlRodLevel(0)   --%
  22.   local fuelCons = r.getFuelConsumedLastTick() --mB
  23.  
  24.   mon.clear()
  25.   mon.setBackgroundColor(colors.black)
  26.      
  27.   --Reactor Online
  28.   mon.setCursorPos(1,1)
  29.   mon.setTextColor(colors.white)
  30.   mon.write("Active: ")
  31.   if reactorOnline then
  32.     mon.setTextColor(colors.lime)
  33.   else
  34.     mon.setTextColor(colors.red)
  35.   end      
  36.   if reactorOnline then
  37.     mon.write("True")
  38.   else
  39.     mon.write("False")
  40.   end    
  41.  
  42.   --RF/t Production
  43.   mon.setCursorPos(1,2)
  44.   mon.setTextColor(colors.white)
  45.   mon.write("RF/t: ")
  46.   if energyProduction <= 0 then
  47.     mon.setTextColor(colors.red)
  48.   else  
  49.     mon.setTextColor(colors.lime)
  50.   end  
  51.   mon.write(math.floor(energyProduction).." RF/t")    
  52.  
  53.   --Energy Stored
  54.   mon.setCursorPos(1,3)
  55.   mon.setTextColor(colors.white)
  56.   mon.write("Energy Stored: ")
  57.   if energyStored < 1000000 then
  58.     mon.setTextColor(colors.red)
  59.   else
  60.     mon.setTextColor(colors.lime)
  61.   end  
  62.   mon.write(math.floor(energyStored).." RF")
  63.  
  64.   --Fuel Temp
  65.   mon.setCursorPos(1,4)
  66.   mon.setTextColor(colors.white)
  67.   mon.write("Fuel Temp: ")
  68.   mon.setTextColor(colors.lime)
  69.   mon.write(math.floor(fuelTemp).." C")
  70.  
  71.   --Case Temp
  72.   mon.setCursorPos(1,5)
  73.   mon.setTextColor(colors.white)
  74.   mon.write("Case Temp: ")
  75.   mon.setTextColor(colors.lime)
  76.   mon.write(math.floor(caseTemp).." C")
  77.  
  78.   --Fuel Reactivity
  79.   mon.setCursorPos(1,6)
  80.   mon.setTextColor(colors.white)
  81.   mon.write("Fuel React: ")
  82.   mon.setTextColor(colors.lime)
  83.   mon.write(math.floor(fuelReact).."%")
  84.  
  85.   --Fuel Amount
  86.   mon.setCursorPos (1,7)
  87.   mon.setTextColor(colors.white)
  88.   mon.write("Fuel: ")
  89.   mon.setTextColor(colors.lime)
  90.   mon.write(math.floor(fuelAmount).." mB")
  91.  
  92.   --Fuel Consumption
  93.   mon.setCursorPos(1,8)
  94.   mon.setTextColor(colors.white)
  95.   mon.write("Fuel Use: ")
  96.   mon.setTextColor(colors.lime)
  97.   if fuelCons > 0 then
  98.     mon.write("~")
  99.   end
  100.   mon.write(math.floor(fuelCons * 100 / 10).." mB/t")
  101.  
  102.   --Waste Amount
  103.   mon.setCursorPos (1,9)
  104.   mon.setTextColor(colors.white)
  105.   mon.write("Waste: ")
  106.  
  107.   if wasteAmount >= 900 then
  108.     mon.setTextColor(colors.red)
  109.   else
  110.     mon.setTextColor(colors.lime)
  111.   end  
  112.   mon.write(math.floor(wasteAmount).." mB")
  113.          
  114.   --Activation Button Display
  115.   if reactorOnline then
  116.     mon.setCursorPos(19,1)
  117.     mon.setTextColor(colors.red)
  118.   else
  119.     mon.setCursorPos(22,1)
  120.     mon.setTextColor(colors.lime)
  121.   end
  122.   if reactorOnline then
  123.     mon.write("De-Activate")
  124.   else
  125.     mon.write("Activate")
  126.   end    
  127.  
  128.   --Rod Controller Display
  129.   mon.setCursorPos(24,7)
  130.   mon.setTextColor(colors.white)
  131.   mon.write("Rods")
  132.   if rodLevel == 0 then
  133.     mon.setCursorPos(25,8)
  134.   else
  135.     mon.setCursorPos(24,8)
  136.   end  
  137.   mon.write(rodLevel.."%")
  138.   mon.setCursorPos(22,8)
  139.   mon.write("<")
  140.   mon.setCursorPos(29,8)
  141.   mon.write(">")
  142.  
  143.   --Button Timers
  144.   local myTimer = os.startTimer(1)
  145.   local event, side, x, y = os.pullEvent()
  146.   if event == "monitor_touch" and y == 1 and x < 30 and x > 18 and reactorOnline then
  147.     r.setActive(false)
  148.   elseif event == "monitor_touch" and y == 1 and x < 30 and x > 21 then
  149.     r.setActive(true)
  150.   elseif event == "monitor_touch" and y == 8 and x == 22 then
  151.     r.setAllControlRodLevels(rodLevel - 10)
  152.   elseif event == "monitor_touch" and y == 8 and x == 29 then
  153.     r.setAllControlRodLevels(rodLevel + 10)  
  154.   end  
  155.   os.cancelTimer(myTimer)
  156. end
Add Comment
Please, Sign In to add comment