ratismal

ReactorControl

Aug 10th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. local rea = peripheral.wrap("BigReactors-Reactor_0")
  2. local mon = peripheral.wrap("monitor_1")
  3.  
  4. function display()
  5.  mon.setTextColor( colors.white )
  6.  energy = math.floor(rea.getEnergyStored())
  7.  energyString = string.sub(energy .. "RF        ", 1, 11)
  8.  mon.setCursorPos(4, 1)
  9.  mon.write(energyString)
  10.  mon.setCursorPos(14,1)
  11.  mon.write(" / 10000000RF")
  12.  percent = math.floor(energy / 10000000 * 100)
  13.  mon.setCursorPos(10, 2)
  14.  percentString = string.sub(percent .. "    ", 1, 3)
  15.  mon.write(percentString)
  16.  mon.setCursorPos(13,2)
  17.  mon.write("% full")
  18.  mon.setCursorPos(11, 4)
  19.  if percent == 100 then
  20.   rea.setActive(false)
  21.  elseif percent < 20 then
  22.   rea.setActive(true)
  23.  end
  24.  
  25.  if rea.getActive() then
  26.   mon.setBackgroundColor( colors.green )
  27.   mon.write("ENABLED ")
  28.   mon.setBackgroundColor( colors.black)
  29.  else
  30.   mon.setBackgroundColor( colors.red )
  31.   mon.write("DISABLED")
  32.  end
  33. end
  34.  
  35. mon.clear()
  36. while true do
  37.  
  38.  os.queueEvent("reactorControl")
  39.  os.pullEvent()
  40.  display()
  41.  os.sleep(10)
  42. end
Advertisement
Add Comment
Please, Sign In to add comment