Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  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. log("\tFunctions: ")
  44. for _,pFunc in ipairs(peripheral.wrap(pSide)) do
  45. log("\t\t" ..pFunc)
  46. end
  47. end
  48.  
  49. log("Turbines:")
  50. for i, pSide in ipairs(turbines) do
  51. log("\t" ..i.. ":\t" ..pSide)
  52. end
  53.  
  54. log("Monitors:")
  55. for i, pSide in ipairs(monitors) do
  56. log("\t" ..i.. ":\t" ..pSide)
  57. end
  58. end
  59.  
  60. function showReactorInfo()
  61. for _, pSide in ipairs(reactors) do
  62. log("Reactor '" ..pSide.. "': ")
  63. end
  64. end
  65.  
  66. function showTurbineInfo()
  67. for _, pSide in ipairs(turbines) do
  68. log("Turbine '" ..pSide.. "': ")
  69. log("\t ")
  70. end
  71. end
  72.  
  73. log ("Turbine max energy: " ..turbineMaxEnergy)
  74. log ("Reactor max temp:" ..reactorMaxTemp)
  75.  
  76. updatePeripherals()
  77. listPeripherals()
  78. showReactorInfo()
  79. showTurbineInfo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement