Advertisement
HangMan23

Untitled

Feb 7th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. local g = require("component").glasses
  2. local reactor = require("component").reactor
  3. local sides = require("sides")
  4. local red = require("component").redstone
  5. local event = require("event")
  6. local gpu = require("component").gpu
  7. local mfe = require("component").ic2_te_mfe
  8.  
  9. red.setOutput(sides.down, 0)
  10.  
  11. g.removeAll()
  12.  
  13. function newButton(massive, x, y, w, h, color, func)
  14.  
  15. massive[#massive + 1] = {g.addRect(), func}
  16. massive[#massive][1].setColor(color[1], color[2], color[3])
  17. massive[#massive][1].setSize(w, h)
  18. massive[#massive][1].setPosition(x, y)
  19.  
  20. return massive
  21.  
  22. end
  23.  
  24. local eu = g.addTextLabel()
  25. local heat = g.addTextLabel()
  26. eu.setPosition(23, 7)
  27. eu.setScale(0.6)
  28. eu.setColor(0, 1/0.3, 1/0.3)
  29. os.sleep(0.1)
  30. heat.setPosition(23, 14)
  31. heat.setScale(0.6)
  32. heat.setColor(0, 1/0.3, 1/0.3)
  33. os.sleep(0.1)
  34. local status = g.addTextLabel()
  35. status.setText("status: waiting")
  36. status.setPosition(2, 21)
  37. status.setScale(0.6)
  38. status.setColor(1,1,1)
  39. local energySub = g.addRect()
  40. local energyFore = g.addRect()
  41. energySub.setColor(37/100, 42/100, 101/100)
  42. energyFore.setColor(1, 1, 0)
  43. energySub.setSize(50, 3)
  44. energyFore.setSize(50, 0)
  45. energySub.setPosition(1, 18)
  46. energyFore.setPosition(1, 18)
  47. energyText = g.addTextLabel()
  48. energyText.setScale(0.6)
  49. energyText.setColor(0, 1/0.3, 1/0,3)
  50. energyText.setPosition(2, 35)
  51.  
  52. function info()
  53.  
  54. progressBarFore.setSize(reactor.getHeat() / 100 / 2, 3)
  55. energyFore.setSize((100 / (mfe.getCapacity() / mfe.getEnergy())) / 2, 3)
  56. energyText.setText("MFE: " .. math.floor(mfe.getEnergy()) .. "/" .. math.floor(mfe.getCapacity()) .. " (" .. math.floor((100 / (mfe.getCapacity() / mfe.getEnergy()))) .. "%)")
  57.  
  58. if reactor.getHeat() / 100 >= 80 and red.getOutput(sides.down) > 0 then red.setOutput(sides.down, 0) buttons[1][1].setColor(1, 1, 0) status.setText("status: interrupted")end
  59.  
  60. eu.setText("EU Output: " .. reactor.getReactorEnergyOutput())
  61. heat.setText("Heat: " .. reactor.getHeat() / 100 .. "%")
  62.  
  63. end
  64.  
  65.  
  66.  
  67. function pull(massive)
  68.  
  69. while not massive.close do
  70.  
  71. local type, _, _, x, y, mode = event.pull(0.1)
  72.  
  73. for i = 1, #massive do
  74.  
  75. local posX, posY = massive[i][1].getPosition()
  76. local w, h = massive[i][1].getSize()
  77.  
  78. if type == "interact_overlay" then
  79.  
  80. if x >= posX and x < w + posX and y >= posY and y < h + posY then
  81.  
  82. massive[i][2]()
  83.  
  84. end
  85.  
  86. end
  87.  
  88. end
  89.  
  90. info()
  91.  
  92. end
  93.  
  94. end
  95.  
  96. progressBarBack = g.addRect()
  97. progressBarBack.setColor(49 / 100, 49 / 100, 49 / 100)
  98. progressBarBack.setSize(50, 3)
  99. progressBarBack.setPosition(1, 1)
  100. progressBarFore = g.addRect()
  101. progressBarFore.setColor(1, 0, 0)
  102. progressBarFore.setPosition(1, 1)
  103.  
  104. OnOff = g.addRect()
  105. OnOff.setSize(12, 8)
  106. OnOff.setColor(0, 1, 0)
  107. OnOff.setPosition(1, 5)
  108.  
  109. function OOF()
  110.  
  111. if red.getOutput(sides.down) > 0 then
  112.  
  113. OnOff.setColor(0, 1, 0)
  114. red.setOutput(sides.down, 0)
  115. status.setText("status: waiting")
  116.  
  117. else
  118.  
  119. OnOff.setColor(1, 0, 0)
  120. red.setOutput(sides.down, 15)
  121. status.setText("status: working")
  122.  
  123. end
  124.  
  125. end
  126.  
  127. function exit()
  128.  
  129. red.setOutput(sides.down, 0)
  130. buttons.close = true
  131.  
  132. end
  133.  
  134. buttons = {
  135.  
  136. {OnOff, OOF}
  137.  
  138. }
  139.  
  140. buttons = newButton(buttons, 640 - 6, 1, 5, 5, {1,0,0}, exit)
  141.  
  142. info()
  143.  
  144. os.sleep(0.1)
  145.  
  146. pull(buttons)
  147.  
  148. g.removeAll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement