Advertisement
ccraftersanonmoose

Mekanism Fission Reactor Monitor and Controller for Computercraft

Feb 5th, 2023 (edited)
177
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | Gaming | 0 0
  1. -- Fission Reactor Controller
  2. -- Test script by ccraftersanonmoose
  3. ----------------------------------------
  4. -- Version History
  5. -- Version 0.1 - 2/5/23
  6. -- added buttons to activate and scram reactor
  7. -- Version 0.2 2/13/23
  8. -- added monitoring of actual burn rate and temp
  9. -- adjusted temp to show absolute number in celsius
  10. -- would ike to add buttons to increment and decrement the burn rate
  11. -- version 0.2.1 2/16/23
  12. -- added status monitoring
  13. -- added set burn rate monitoring
  14. -- trying to add buttons for burn rate
  15.  
  16. ----------------------------------------
  17.  
  18. os.loadAPI("button")
  19. mon = peripheral.find("monitor")
  20. reactor = peripheral.find("fissionReactorLogicAdapter")
  21. mon.clear()
  22.  
  23. function fillTable()
  24. button.setTable("Acivate", activateReactor, 10,20,3,5)
  25. button.setTable("SCRAM", scramReactor, 22,32,3,5)
  26. button.setTable("+", incrementBurnRate, 1,3,5,7)
  27. button.setTable("-", decrementBurnRate, 5,7,5,7)
  28. button.screen()
  29. end
  30.  
  31. function getClick()
  32. event,side,x,y = os.pullEvent("monitor_touch")
  33. button.checkxy(x,y)
  34. end
  35.  
  36. function activateReactor()
  37. button.flash("Activate")
  38. reactor.activate()
  39. end
  40.  
  41. function scramReactor()
  42. button.flash("SCRAM")
  43. reactor.scram()
  44. end
  45.  
  46. function incrementBurnRate()
  47. button.flash("+")
  48. reactor.setBurnRate(reactor.getBurnRate() + 1)
  49. end
  50.  
  51. function decrementBurnRate()
  52. button.flash("+")
  53. reactor.setBurnRate(reactor.getBurnRate() - 1)
  54. end
  55. --function getInfo()
  56. --reactor.getActualBurnRate()
  57. --reactor.getCoolantFilledPercentage()
  58. --reactor.getFuelFilledPercentage()
  59. --reactor.getTemperature()
  60. --reactor.getStatus()
  61. --end
  62.  
  63. function displayInfo()
  64. mon.setTextScale(1)
  65. if reactor.getStatus() == true then
  66. mon.setCursorPos(1,1)
  67. mon.write("Status:")
  68. mon.setCursorPos(1,2)
  69. mon.clearLine()
  70. mon.write("Active")
  71. else
  72. mon.setCursorPos(1,1)
  73. mon.write("Status:")
  74. mon.setCursorPos(1,2)
  75. mon.clearLine()
  76. mon.write("Disabled")
  77. end
  78. mon.setCursorPos(1,3)
  79. mon.write("Burn Rate")
  80. mon.setCursorPos(1,4)
  81. mon.write(reactor.getBurnRate())
  82. mon.setCursorPos(1,8)
  83. mon.write("Current Burn Rate: ")
  84. mon.setCursorPos(1,10)
  85. mon.write(reactor.getActualBurnRate())
  86. mon.setCursorPos(22,8)
  87. mon.write("Current Temp:")
  88. mon.setCursorPos(22,10)
  89. mon.write(math.floor(reactor.getTemperature() - 273.15), "C")
  90. end
  91.  
  92. fillTable()
  93. button.heading("Reactor Controller")
  94.  
  95. while true do
  96. displayInfo()
  97. getClick()
  98. end
  99.  
Advertisement
Comments
  • Pankola
    1 year
    Comment was deleted
Add Comment
Please, Sign In to add comment
Advertisement