DerMarten

[CC]BigReactor Info

Nov 15th, 2015
143
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ------------   Config    --------------
  2. -----------------------------------------
  3. local reactorSide = "bottom"
  4. local monitorName = "monitor_4"
  5. ------------   Variblen    --------------
  6. -----------------------------------------
  7. local runServer
  8. local reactor
  9. local monitor
  10. local reactorEnergyLastTick
  11. local reactorActive
  12. local reactorFuelLevel
  13. local reactorFuelLevelMax
  14. local reactorFuelConsumedLastTick
  15. local reactorEnergyStored
  16. ------------  Functionen   --------------
  17. -----------------------------------------
  18. function init()
  19.     runServer = true
  20.     reactor = peripheral.wrap(reactorSide)
  21.     monitor = peripheral.wrap(monitorName)
  22.     monitor.setTextScale(2)
  23. end
  24. function update()
  25.     reactorEnergyLastTick = reactor.getEnergyProducedLastTick()
  26.     reactorActive = reactor.getActive()
  27.     reactorFuelLevel = reactor.getFuelAmount()
  28.     reactorFuelLevelMax = reactor.getFuelAmountMax()
  29.     reactorFuelConsumedLastTick = reactor.getFuelConsumedLastTick()
  30.     reactorEnergyStored = reactor.getEnergyStored()
  31. end
  32. function paint()
  33.     monitor.clear()
  34.     if reactorActive == true then
  35.         monitor.setBackgroundColor(colors.green)
  36.     else
  37.         monitor.setBackgroundColor(colors.red)
  38.     end
  39.     monitor.setCursorPos(6,1)
  40.     monitor.write("Reactor Info Display")
  41.  
  42.     monitor.setCursorPos(1,3)
  43.     monitor.write("Energy Last Tick: "..reactorEnergyLastTick.." RF/t")
  44.    
  45.     monitor.setCursorPos(1,4)
  46.     if reactorActive == true then
  47.         monitor.write("Reactor Active: True")
  48.     else
  49.         monitor.write("Reactor Active: False")
  50.     end
  51.    
  52.     monitor.setCursorPos(1,5)
  53.     monitor.write("Fuel Level: "..reactorFuelLevel.." / "..reactorFuelLevelMax.." mB")
  54.    
  55.     monitor.setCursorPos(1,6)
  56.     monitor.write("Fuel Consumed Last Tick : "..reactorFuelConsumedLastTick.." mB")
  57.    
  58.     monitor.setCursorPos(1,7)
  59.     monitor.write("Energy Stored : "..reactorEnergyStored.." / 1000000 RF")
  60.    
  61. end
  62. ------------  Programm Loop  --------------
  63. -----------------------------------------
  64. init()
  65. while runServer do
  66.     update()
  67.     paint()
  68.     os.sleep(0.2)
  69. end
RAW Paste Data