pluggeman

Main

Jan 13th, 2019
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. os.loadAPI('/core/Gui')
  2.  
  3. local mon = peripheral.find('monitor')
  4. local reactor = peripheral.wrap('mekanism_machine_1')
  5. local laserAmp = peripheral.wrap('mekanism_machine_2')
  6. local inductionMatrix = peripheral.wrap('mekanism_machine_3')
  7.  
  8. if not mon then error('No monitor found') end
  9. if not reactor then error('No reactor found') end
  10. if not laserAmp then error('No induction matrix found') end
  11. if not inductionMatrix then error('No induction matrix found') end
  12.  
  13. Gui.Label:new({name = 'title',
  14.     text = 'Fusion Reactor Control',
  15.     bounds = {
  16.         x1 = 14,
  17.         x2 = 36,
  18.         y1 = 1,
  19.         y2 = 1
  20.     }
  21. })
  22. Gui.Label:new({name = 'IM_output',
  23.     text = '100  Rf/t',
  24.     bounds = {
  25.         x1 = 2,
  26.         x2 = 10,
  27.         y1 = 3,
  28.         y2 = 3
  29.     }
  30. })
  31. Gui.Label:new({name = 'IM_energy',
  32.     text = '100  Rf/t',
  33.     bounds = {
  34.         x1 = 2,
  35.         x2 = 10,
  36.         y1 = 4,
  37.         y2 = 4
  38.     }
  39. })
  40. Gui.Bar:new({name = 'IM_percent',
  41.     percent = 0,
  42.     bounds = {
  43.         x1 = 2,
  44.         x2 = 10,
  45.         y1 = 4,
  46.         y2 = 4
  47.     }
  48. })
  49.  
  50.  
  51. function updateIMData()
  52.     Gui.labels.IM_output.text = inductionMatrix.getOutput()
  53.     Gui.labels.IM_energy.text = inductionMatrix.getEnergy()
  54.     Gui.bars.IM_percent.percent = math.floor((inductionMatrix.getEnergy() / inductionMatrix.getMaxEnergy() * 100) + 0.5)
  55.    
  56.     Gui.labels.IM_output:draw()
  57.     Gui.labels.IM_energy:draw()
  58.     Gui.bars.IM_percent:draw()
  59. end
  60.  
  61.  
  62. function main()
  63.     while true do
  64.         updateIMData()
  65.        
  66.         os.sleep(1)
  67.     end
  68. end
  69.  
  70.  
  71. term.redirect(mon)
  72. Gui.draw()
  73. parallel.waitForAll(Gui.run, main)
Advertisement
Add Comment
Please, Sign In to add comment