Guest User

Reactor Control

a guest
Nov 28th, 2013
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. --Daelie Nuclear MOX Control Program Version 1.0
  2.  
  3.  
  4. --temperature variables
  5. runningTemp = 36000
  6. shutdownTemp = 37000
  7.  
  8. --interfaces
  9.  
  10. overclockInterface = "east"
  11. coolantInterface = "west"
  12.  
  13. --peripheral
  14. reactor = peripheral.wrap("back")
  15. rednet.open('top')
  16.  
  17. function getHeat()
  18. getHeat = 0
  19. getHeat = reactor.getHeat()
  20. print("Current Temp.: "..getHeat)
  21. end
  22.  
  23. function getOutput()
  24. getOutput = reactor.getEUOutput()
  25. --Output reported 5x lower than should be
  26. getOutput = getOutput*5
  27. print("Current Output (Eu/t): "..getOutput)
  28. end
  29.  
  30. function checkOverheat()
  31. --overheat conditions reactor on shutdowntemp
  32.  
  33. if reactor.isActive() == true then
  34. if getHeat >= shutdownTemp then
  35. --enter the cooldown phase
  36. rednet.send( 1,"off" )
  37. print("Reactor overheating, shutdown")
  38. --loop to swap coolant for overclockers
  39. overclockSlot = 1
  40. for i = 37,40,1 do
  41. reactor.pushItem(coolantInterface, i, 1)
  42. reactor.pullItemIntoSlot(overclockInterface, overclockSlot, 1, i)
  43. overclockSlot = overclockSlot + 1
  44. end
  45. else
  46. print("Reactor currently below shutdown")
  47. end
  48. end
  49. end
  50.  
  51. function restartAfterOverheat()
  52. --reactor would be off, below shutdown
  53. if reactor.isActive() == false then
  54. if getHeat < shutdownTemp then
  55. --reswap the coolants
  56. coolantSlot = 1
  57. for i = 37, 40, 1 do
  58. reactor.pushItem(overclockInterface, i, 1)
  59. reactor.pullItemIntoSlot(coolantInterface, coolantSlot, 1, i)
  60. coolantSlot = coolantSlot + 1
  61. end
  62. --turn back on the reactor
  63. rednet.send( 1,"on" )
  64. end
  65. else
  66. print("Reactor On, No Restart Required")
  67. end
  68. end
  69.  
  70. while true do
  71.  
  72. getHeat()
  73. checkOverheat()
  74. restartAfterOverheat()
  75. sleep(0.8)
  76. end
Advertisement
Add Comment
Please, Sign In to add comment