Guest User

Untitled

a guest
Nov 14th, 2019
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Reactor and turbine control script by EternalClickbait
  2. --Reactor, turbine and monitor must be connected with wired modems to the computer
  3.  
  4. local reactors = {}
  5. local turbines = {}
  6. local monitors = {}
  7.  
  8. --The maximum temperature for the reactor
  9. local reactorMaxTemp = 200
  10. --The maximum energy in our turbine's buffer. Max is 1M (1,000,000)
  11. local turbineMaxEnergy = 500000
  12.  
  13. function log(message)
  14. print(message)
  15. for _, side in ipairs(monitors) do
  16. peripheral.wrap(side).write(message)
  17. end
  18. end
  19.  
  20. --Updates the list of reactors, turbines and monitor
  21. function updatePeripherals()
  22. local peripherals = peripheral.getNames() --Get a list of all the peripherals
  23. log("Peripherals:")
  24. for _, pSide in ipairs(peripherals) do
  25. local pType = peripheral.getType(pSide)
  26. local pFunctions = peripheral.wrap(pSide)
  27.  
  28. if(pType == "BigReactors-Reactor") then --If we found a reactor
  29. table.insert(reactors, pSide)
  30. elseif (pType == "BigReactors-Turbine") then
  31. table.insert(turbines, pSide)
  32. elseif (pType == "monitor") then
  33. table.insert(monitors, pSide)
  34. end
  35. end
  36. end
  37.  
  38. --Lists all of the peripherals connected
  39. function listPeripherals()
  40. log("Reactors:")
  41. for i, pSide in ipairs(reactors) do
  42. log("\t" ..i.. ":\t" ..pSide)
  43. end
  44.  
  45. log("Turbines:")
  46. for i, pSide in ipairs(turbines) do
  47. log("\t" ..i.. ":\t" ..pSide)
  48. end
  49.  
  50. log("Monitors:")
  51. for i, pSide in ipairs(monitors) do
  52. log("\t" ..i.. ":\t" ..pSide)
  53. end
  54. end
  55.  
  56. log ("Turbine max energy: " ..turbineMaxEnergy.. "")
  57. log ("Reactor max temp:" ..reactorMaxTemp.. "")
  58.  
  59. updatePeripherals()
  60. listPeripherals()
RAW Paste Data