wasliebob

reactor

Jul 7th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. os.loadAPI("api")
  2. os.loadAPI("touchpoint")
  3.  
  4. while true do
  5. r = peripheral.wrap("back")
  6. mon = peripheral.wrap("left")
  7. mon.clear()
  8. mon.setTextScale(1)
  9.  
  10. glass = peripheral.wrap("bottom")
  11.  
  12. local t = touchpoint.new("left")
  13. t:add("Toggle", toggle, 1, 17, 29, 19, colors.red, colors.lime)
  14.  
  15. t:draw()
  16.  
  17. mon.setBackgroundColor(colors.black)
  18. mon.setTextColor(colors.white)
  19.  
  20. state = "Null"
  21. stateColor = colors.white
  22. rods = r.getNumberOfControlRods()
  23. rfStored = r.getEnergyStored()
  24. rfCapacity = 10000000
  25. casingTemp = r.getCasingTemperature()
  26. fuelAmount = r.getFuelAmount()
  27. fuelCapacity = r.getFuelAmountMax()
  28. fuelPercent = api.getPercent(fuelAmount, fuelCapacity)
  29. rate = r.getEnergyProducedLastTick()
  30.  
  31. if r.getActive() then state = "Active" else state = "Inactive" end
  32. if r.getActive() then stateColor = colors.green else stateColor = colors.red end
  33.  
  34. function toggle()
  35. if r.getActive() then
  36. r.setActive(false)
  37. else
  38. r.setActive(true)
  39. end
  40. end
  41.  
  42. if rate >= 1000 then
  43. rateConverted = rate / 1000
  44. else
  45. rateConverted = rate
  46. end
  47.  
  48. api.drawStringWithColor(mon, "State: ", 1, 1, colors.white)
  49. api.drawStringWithColor(mon, state, 7, 1, stateColor)
  50.  
  51. api.drawStringWithColor(mon, "Rods: ", 1, 2, colors.white)
  52. api.drawStringWithColor(mon, rods, 6, 2, colors.blue)
  53.  
  54. api.drawStringWithColor(mon, "Stored: ", 1, 3, colors.white)
  55. api.drawStringWithColor(mon, rfStored .. " RF", 8, 3, colors.red)
  56.  
  57. api.drawStringWithColor(mon, "Temperature: ", 1, 4, colors.white)
  58. api.drawStringWithColor(mon, casingTemp .. " C", 13, 4, colors.red)
  59.  
  60. api.drawStringWithColor(mon, "Fuel: ", 1, 5, colors.white)
  61. api.drawStringWithColor(mon, fuelAmount .." mb", 6, 5, colors.blue)
  62.  
  63. api.drawStringWithColor(mon, "Rate: ", 1, 6, colors.white)
  64.  
  65. if rate >= 1000 then
  66. api.drawStringWithColor(mon, math.ceil(rate / 1000) .. " kRF/t", 6, 6, colors.red)
  67. else
  68. api.drawStringWithColor(mon, rate .. " RF/t", 6, 6, colors.red)
  69. end
  70.  
  71. glass.clear()
  72. glass.addBox(1, 1, 140, 46, 0xFFFFFF, 0.2)
  73.  
  74. if r.getActive() then
  75. glass.addText(5, 2, "State: " .. state, 0x66FF33)
  76. else
  77. glass.addText(5, 2, "State: " .. state, 0xFF0000)
  78. end
  79.  
  80. glass.addText(5, 11, "Stored: " .. rfStored .. " RF", 0x66FF33)
  81. glass.addText(5, 20, "Temperature: " .. casingTemp .. " C", 0x66FF33)
  82. glass.addText(5, 29, "Fuel: " .. fuelAmount .." mb", 0x66FF33)
  83.  
  84. if rate >= 1000 then
  85. glass.addText(5, 38, "Rate: " .. math.ceil(rate / 1000) .. " kRF/t", 0x66FF33)
  86. else
  87. glass.addText(5, 38, "Rate: " .. rate .. " RF/t", 0x66FF33)
  88. end
  89. glass.sync()
  90.  
  91. local event, p1 = t:handleEvents(os.pullEvent())
  92. if event == "button_click" then
  93. t.buttonList[p1].func()
  94. end
  95.  
  96. sleep(3)
  97. end
Advertisement
Add Comment
Please, Sign In to add comment