Advertisement
Guest User

energyLevel

a guest
Feb 23rd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. local monitor = peripheral.wrap("monitor_1")
  2. local battery = peripheral.wrap("Induction Matrix_1")
  3. local white = 1
  4. local orange = 2
  5. local magenta = 4
  6. local lightBlue = 8
  7. local yellow = 16
  8. local lime = 32
  9. local pink = 64
  10. local gray = 128
  11. local lightGray = 256
  12. local cyan = 512
  13. local purple = 1024
  14. local blue = 2048
  15. local brown = 4096
  16. local green = 8192
  17. local red = 16384
  18. local black = 32768
  19. function setTextScale(size)
  20.     monitor.setTextScale(size)
  21. end
  22. function setTextColor(color)
  23.     monitor.setTextColor(color)
  24. end
  25. function setCursorPos(x, y)
  26.     monitor.setCursorPos(x, y)
  27. end
  28. function setBgColor(color)
  29.     monitor.setBackgroundColor(color)
  30. end
  31. function write(str)
  32.     monitor.write(str)
  33. end
  34. monitor.clear()
  35. setBgColor(black)
  36. setTextScale(0.5)
  37. setTextColor(green)
  38. setCursorPos(1,1)
  39. write("Capacity:")
  40. setCursorPos(1,2)
  41. write("Input:")
  42. setCursorPos(1,3)
  43. write("Output:")
  44. setCursorPos(1,4)
  45. write("Energy level")
  46. setCursorPos(1,5)
  47. setTextColor(lightBlue)
  48. for i = 1, 36 do
  49.     write("#")
  50. end
  51. for i = 1, 4 do
  52.     setCursorPos(1, i + 5)
  53.     write("#")
  54.     setCursorPos(36, i + 5)
  55.     write("#")
  56. end
  57. setCursorPos(1, 10)
  58. for i = 1, 36 do
  59.     write("#")
  60. end
  61. setTextColor(green)
  62. local cof = 10000000
  63. local capacity
  64. local output
  65. local proc
  66. --Cycle
  67.  
  68. setCursorPos(10,1)
  69. capacity = battery.getEnergy()
  70. write(math.floor(capacity / cof * 4) / 1000)
  71. write(" GRF")
  72. setCursorPos(10,2)
  73. input = battery.getInput()
  74. write(input / 4)
  75. write(" RF/t")
  76. setCursorPos(10,3)
  77. output = battery.getOutput()
  78. write(output / 4)
  79. write(" RF/t")
  80. proc = capacity / battery.getMaxEnergy()
  81. if proc > 0.7 then
  82.     setTextColor(green)
  83.     setBgColor(green)
  84. elseif proc > 0.3 then
  85.     setTextColor(orange)
  86.     setBgColor(orange)
  87. elseif proc <= 0.3 then
  88.     setTextColor(red)
  89.     setBgColor(red)
  90. end
  91. for i = 1, 4 do
  92.     for j = 1, 34 * proc do
  93.         setCursorPos(j + 1,i + 5)
  94.         write("i")
  95.     end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement