Advertisement
Margresse404

reactorwithuserinput

May 29th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. local monitors
  2. monitors = peripheral.wrap("right")
  3. local reactor
  4. monitors.write("Enter the reactor number")
  5.  
  6. function newLine()
  7. local x
  8. local y
  9. x, y = monitors.getCursorPos()
  10. y = y + 1
  11. monitors.setCursorPos(1,y)
  12. end
  13.  
  14. newLine()
  15. local reactorNumber = read()
  16. reactor = peripheral.wrap("BigReactors-Reactor_"..tostring(reactorNumber))
  17. local energyStored
  18.  
  19. function writeToScreen(text)
  20. monitors.clear()
  21. monitors.setCursorPos(1,1)
  22. active = reactor.getActive()
  23. monitors.write("Reactor Control Program")
  24. newLine()
  25. monitors.write("Reactor active:")
  26. newLine()
  27. monitors.write(active)
  28. newLine()
  29. monitors.write("Energy stored:")
  30. newLine()
  31. monitors.write(energyStored)
  32. newLine()
  33. monitors.write(text)
  34. newLine()
  35. end
  36.  
  37. energyStored = reactor.getEnergyStored()
  38. monitors.write("Enter a waiting time, good values are 50-100 ish.")
  39. newLine()
  40. monitors.write("Should be a factor of 10")
  41. newLine()
  42.  
  43. local offlineWaitingTime = tonumber(read())
  44. local increment = offlineWaitingTime / 10
  45. print("Input given:"..tostring(offlineWaitingTime))
  46.  
  47. while true do --Always loop
  48.  
  49. energyStored = reactor.getEnergyStored()
  50.  
  51. if energyStored == 0 then
  52. reactor.setActive(true)
  53. writeToScreen("No energy stored, starting reactor")
  54. monitors.write("Waiting for 3 seconds total")
  55. newLine()
  56. for i=1,3 do
  57. monitors.write(tostring(i) )
  58. newLine()
  59. sleep(1)
  60. end
  61. energyStored = reactor.getEnergyStored()
  62. end
  63.  
  64. if energyStored > 2000000 then
  65. reactor.setActive(false)
  66. writeToScreen("too much energy, stopped reactor")
  67.  
  68. monitors.write("Waiting for "..tostring(offlineWaitingTime).." seconds total")
  69. newLine()
  70.  
  71. local j = 0
  72.  
  73. for i=1,increment do
  74. local casingHeat = reactor.getCasingTemperature()
  75. j = i * 10
  76. if casingHeat < 30 then
  77. end
  78. monitors.write(tostring(casingHeat))
  79. newLine()
  80. monitors.write(tostring(j))
  81. newLine()
  82. sleep(10)
  83. end
  84. end
  85.  
  86. writeToScreen("Loading reactor till its full enough")
  87. monitors.write("Waiting for 3 seconds total")
  88. newLine()
  89. for i=1,3 do
  90. monitors.write(tostring(i))
  91. newLine()
  92. sleep(1)
  93. end
  94.  
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement