Advertisement
Guest User

Untitled

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