Advertisement
Guest User

startup

a guest
Sep 4th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.10 KB | None | 0 0
  1. --Finding the Reactor & Monitor--
  2. local reactor = peripheral.find("BigReactors-Reactor")
  3. local mon = peripheral.find("monitor")
  4.  
  5. --Functions--
  6. local function percentMe(currentValue, maxValue)
  7.   return math.floor((100 * currentValue) / maxValue)
  8. end
  9.  
  10. --Main Code--
  11. while true do
  12.  
  13.   --Variables--
  14.   local maxEnergy = 1000000
  15.   local storedEnergy = math.floor(reactor.getEnergyStored())
  16.   local percentageEnergy = percentMe(storedEnergy, maxEnergy)
  17.  
  18.   local storedTemperature = reactor.getFuelTemperature()
  19.  
  20.   local storedFuel = reactor.getFuelAmount()
  21.   local storedWaste = reactor.getWasteAmount()
  22.  
  23.   local status
  24.   local statusColor
  25.  
  26.   --if Statements--
  27.   if percentageEnergy > 90 then
  28.     reactor.setActive(false)
  29.   else
  30.     reactor.setActive(true)
  31.   end
  32.   --
  33.   if reactor.getActive() then
  34.     statusColor = colors.lime
  35.     status = "Online"
  36.   else
  37.     statusColor = colors.red
  38.     status = "Offline"
  39.   end
  40.   --
  41.  
  42.   --Monitor Drawing--
  43.   mon.clear()
  44.   mon.setBackgroundColor(colors.black)
  45.   mon.setTextScale(5)
  46.   mon.setTextScale(0.5)
  47.  
  48.   mon.setCursorPos(7,1)
  49.   mon.setTextColor(colors.orange)
  50.   mon.write("[SC] Reactor Controller")
  51.  
  52.   mon.setCursorPos(1,3)
  53.   mon.setTextColor(colors.white)
  54.   mon.write("Reactor Status      : ")
  55.   mon.setCursorPos(22,3)
  56.   mon.setTextColor(statusColor)
  57.   mon.write(status)
  58.  
  59.   mon.setCursorPos(1,4)
  60.   mon.setTextColor(colors.white)
  61.   mon.write("Stored Energy       : ")
  62.   mon.setCursorPos(22,4)
  63.   mon.setTextColor(colors.white)
  64.   mon.write(tostring(storedEnergy))
  65.  
  66.   mon.setCursorPos(1,5)
  67.   mon.setTextColor(colors.white)
  68.   mon.write("Temperature         : ")
  69.   mon.setCursorPos(22,5)
  70.   mon.setTextColor(colors.white)
  71.   mon.write(storedTemperature)
  72.  
  73.   mon.setCursorPos(1,6)
  74.   mon.setTextColor(colors.white)
  75.   mon.write("Stored Fuel         : ")
  76.   mon.setCursorPos(22,6)
  77.   mon.setTextColor(colors.yellow)
  78.   mon.write(storedFuel)
  79.  
  80.   mon.setCursorPos(1,7)
  81.   mon.setTextColor(colors.white)
  82.   mon.write("Stored Waste        : ")
  83.   mon.setCursorPos(22,7)
  84.   mon.setTextColor(colors.orange)
  85.   mon.write(storedWaste)
  86.  
  87.   sleep(1)
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement