Advertisement
Spatzenhirn123

Nuclear-Controll

May 6th, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.51 KB | None | 0 0
  1. print('ReactorControl Engaged. View Monitor.')
  2.  
  3. emptyflag=0
  4. offlineflag=0
  5. flashflag=0
  6.  
  7. reactor=peripheral.wrap('back')
  8. monitor=peripheral.wrap('left')
  9.  
  10. monitor.setTextScale(1)
  11. monitor.setBackgroundColor(colors.black)
  12.  
  13. while true do
  14. monitor.clear()
  15. monitor.setTextColor(colors.white)
  16. monitor.setCursorPos(1,3)
  17. monitor.setTextColor(colors.yellow)
  18. monitor.write(math.floor(((reactor.getFuelAmount()/reactor.getFuelAmountMax())*100)+0.5)..'% Fuel')
  19. monitor.setCursorPos(11,3)
  20. monitor.setTextColor(colors.lightBlue)
  21. monitor.write(math.floor(((reactor.getWasteAmount()/reactor.getFuelAmountMax())*100)+0.5)..'% Waste')
  22.  
  23. monitor.setCursorPos(1,1)
  24. monitor.setTextColor(colors.white)
  25. monitor.write('Reactor at:')
  26. monitor.setTextColor(colors.green)
  27. monitor.setCursorPos(13,1)
  28. monitor.write(''..(100-(reactor.getControlRodLevel(0)))..'%')
  29.  
  30. monitor.setCursorPos(1,2)
  31. monitor.setTextColor(colors.white)
  32. monitor.write('RF per tick:')
  33. monitor.setCursorPos(13,2)
  34.  
  35.  
  36. if reactor.getEnergyProducedLastTick()>=500 and reactor.getEnergyProducedLastTick()<2000 then
  37.     monitor.setTextColor(colors.orange)
  38. end
  39.  
  40. if reactor.getEnergyProducedLastTick()>=2000 then
  41.     monitor.setTextColor(colors.red)
  42. end
  43. monitor.write((math.floor(reactor.getEnergyProducedLastTick()+0.5))..'')
  44.  
  45. monitor.setCursorPos(1,4)
  46. monitor.setTextColor(colors.orange)
  47. monitor.write('Warnings:')
  48.  
  49. if flashflag==0 then
  50.   flashflag=1
  51.   if offlineflag==1 then
  52.     monitor.setCursorPos(1,5)
  53.     monitor.setTextColor(colors.lightGray)
  54.     monitor.write('OFFLINE - Manual')
  55.   end
  56.   if emptyflag==1 then
  57.     monitor.setCursorPos(1,5)
  58.     monitor.setTextColor(colors.pink)
  59.     monitor.write('OFFLINE - Fuel!!')
  60.   end
  61.   if emptyflag==0 and offlineflag==0 then
  62.     monitor.setCursorPos(1,5)
  63.     monitor.setTextColor(colors.yellow)
  64.     monitor.write('ONLINE')
  65.   end
  66. else
  67.   flashflag=0
  68.   monitor.setCursorPos(1,5)
  69.   monitor.clearLine()
  70. end
  71.  
  72. if reactor.getEnergyStored()<=9900000 then
  73.     reactor.setAllControlRodLevels(0+(math.floor(reactor.getEnergyStored()/100000)))
  74. end
  75.  
  76. if reactor.getFuelAmount()<=(reactor.getFuelAmountMax()/2) and offlineflag==0 then
  77.     reactor.setAllControlRodLevels(100)
  78.     reactor.setActive(false)
  79.     emptyflag=1
  80. else
  81.     emptyflag=0
  82. end
  83.      
  84. if rs.getInput('right')==false and emptyflag==0 then
  85.     reactor.setActive(true)
  86.     offlineflag=0
  87. end
  88.  
  89. if rs.getInput('right')==true and emptyflag==0 then
  90.     reactor.setActive(false)
  91.     reactor.setAllControlRodLevels(100)
  92.     offlineflag=1
  93. end    
  94. sleep(1)
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement