SHARE
TWEET

Untitled

a guest Jul 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("Starting Reactor Controller")
  2. print("Version 1")
  3. print("By Bixilon")
  4.  
  5. --Init Modem
  6.  
  7. local modem_connected = false
  8.  
  9.  
  10. for _, side in pairs(rs.getSides()) do
  11.   if peripheral.getType(side) == "modem" then
  12.     modem_connected = true
  13.     rednet.open(side)
  14.   end
  15. end
  16.  
  17. if not modem_connected then
  18.   print("A modem was not found, please attach one and re-run this program")
  19.   stop()
  20. else
  21.   print("A modem was found! Connecting...")
  22. end
  23.  
  24. --Connecting done
  25.  
  26. local mode = 0 -- 0 = unset, 1 = controller (monitor), 2 = reactor controller, 3 = turbine controller
  27.  
  28.  
  29. --Init Reactor
  30.  
  31. local reactor_connected = false
  32. local reactor = nil
  33.  
  34. for _, side in pairs(rs.getSides()) do
  35.   if peripheral.getType(side) == "BigReactors-Reactor" then
  36.     reactor_connected = true
  37.     reactor = peripheral.wrap(side)
  38.   end
  39. end
  40.  
  41.  
  42. --Init Turbine
  43.  
  44. local turbine_connected = false
  45. local turbine = nil
  46.  
  47. for _, side in pairs(rs.getSides()) do
  48.   if peripheral.getType(side) == "BigReactors-Turbine" then
  49.     turbine_connected = true
  50.     turbine = peripheral.wrap(side)
  51.   end
  52. end
  53.  
  54. --Init Monitor
  55.  
  56. local monitor_connected = false
  57. local monitor = nil
  58.  
  59. for _, side in pairs(rs.getSides()) do
  60.   if peripheral.getType(side) == "monitor" then
  61.     monitor_connected = true
  62.     monitor = peripheral.wrap(side)
  63.   end
  64. end
  65.  
  66.  
  67. --Detect mode
  68. if monitor_connected then
  69.   mode = 1 -- Prio 1
  70.   print("Monitor connceted! I am THE controller now")
  71. elseif reactor_connected then
  72.   mode = 2 -- Prio 2
  73.   print("Reactor connected! I am a reactor controller now")
  74. elseif turbine_connected then
  75.   mode = 2 -- Prio 3
  76.   print("Turbine connceted! I am a turbine controller now")
  77. else
  78.   print("There is no monitor/turbine/reactor attatched! Please attatch one and re-run the program")
  79.   stop()
  80. end
  81.  
  82.  
  83.  
  84. --Reactor Controller (init)
  85. if mode == 2 then
  86.   if not reactor.getConnected() then
  87.     -- Reactor does not work
  88.     print("Reactor is broken!")
  89.     stop()
  90.   end
  91.   if not reactor.isActivelyCooled() then
  92.     -- Reaktor does not produce steam!
  93.     print("Reactor does not produce steam")
  94.   end
  95. end
  96.  
  97.  
  98. --Turbine Controller (init)
  99. if mode == 3 then
  100.   if not turbine.getConnected() then
  101.     -- Turbine does not work
  102.     print("Turbine is broken!")
  103.     stop()
  104.   end
  105. end
  106.  
  107.  
  108. print("Program started...")
  109. while true do
  110.   if mode == 1 then
  111.   end
  112.   if mode == 2 then
  113.     print("Coolant: " ..reactor.getCoolantAmount())
  114.     print("Hot: " ..reactor.getHotFluidAmount())
  115.     print("Hot-Type: " ..reactor.getHotFluidType())
  116.     print("Fuel: " ..reactor.getFuelAmount())
  117.     print("Fuel-Max: " ..reactor.getFuelAmountMax())
  118.     print("Waste: " ..reactor.getWasteAmount())
  119.     print("Rods: " ..reactor.getNumberOfControlRods())
  120.   end
  121.   if mode == 3 then
  122.   end
  123.   --Sleep to avoid warning
  124.   sleep(1)
  125. end
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135. --End
  136. function stop()
  137.   print("Stopping")
  138.   for _, side in pairs(rs.getSides()) do
  139.     if peripheral.getType(side) == "modem" then
  140.       present = true
  141.       rednet.close(side)
  142.     end
  143.   end
  144.   print("Stopped!")
  145.   do return end
  146. end
  147. stop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top