Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 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. --Prints a message to all monitors/windows
  14. function log(message)
  15. print(message)
  16. for _, side in ipairs(monitors) do
  17. peripheral.wrap(side).write(message)
  18. end
  19. end
  20.  
  21. --Sets the scales on all monitors for easily visible text
  22. function setMonitorScales(scale)
  23. for _, side in ipairs(monitors) do
  24. local m = peripheral.wrap(side)
  25. m.setTextScale(tonumber(scale))
  26. end
  27. end
  28.  
  29. --Clears all monitors/windows
  30. function clear()
  31. term.clear()
  32. for _, side in ipairs(monitors) do
  33. peripheral.wrap(side).clear()
  34. peripheral.wrap(side).setCursorPos(1,1)--Reset the cursor position
  35. end
  36. term.setCursorPos(1,1)
  37. end
  38.  
  39. --Updates the list of reactors, turbines and monitor
  40. function updatePeripherals()
  41. local peripherals = peripheral.getNames() --Get a list of all the peripherals
  42. log("Peripherals:")
  43. for _, pSide in ipairs(peripherals) do
  44. local pType = peripheral.getType(pSide)
  45. local pFunctions = peripheral.wrap(pSide)
  46.  
  47. if(pType == "BigReactors-Reactor") then --If we found a reactor
  48. table.insert(reactors, pSide)
  49. elseif (pType == "BigReactors-Turbine") then
  50. table.insert(turbines, pSide)
  51. elseif (pType == "monitor") then
  52. table.insert(monitors, pSide)
  53. end
  54. end
  55. end
  56.  
  57. --Lists all of the peripherals connected
  58. function listPeripherals()
  59. log("Reactors:")
  60. for i, pSide in ipairs(reactors) do
  61. log("\t" ..i.. ":\t" ..pSide)
  62. end
  63.  
  64. log("Turbines:")
  65. for i, pSide in ipairs(turbines) do
  66. log("\t" ..i.. ":\t" ..pSide)
  67. end
  68.  
  69. log("Monitors:")
  70. for i, pSide in ipairs(monitors) do
  71. log("\t" ..i.. ":\t" ..pSide)
  72. end
  73. end
  74.  
  75.  
  76. --Updates all info on screen
  77. function update()
  78. --Clear the window(s)
  79. clear()
  80. end
  81.  
  82. log ("Turbine max energy: " ..turbineMaxEnergy)
  83. log ("Reactor max temp:" ..reactorMaxTemp)
  84.  
  85. updatePeripherals()
  86. listPeripherals()
  87. sleep(2)
  88. local i = 0.5
  89. while true do
  90. update()
  91. log("Current scale: " ..i)
  92. i = i +0.1
  93. sleep(0.5)
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement