SHARE
TWEET

Untitled

a guest Nov 15th, 2019 82 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. --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. --Clears all monitors/windows
  22. function clear()
  23.   term.clear()
  24.   for _, side in ipairs(monitors) do
  25.     peripheral.wrap(side).clear()
  26.     peripheral.wrap(side).setCursorPos(1,1)
  27.   end
  28.   term.setCursorPos(1,1)
  29. end
  30.  
  31. --Updates the list of reactors, turbines and monitor
  32. function updatePeripherals()
  33.   local peripherals = peripheral.getNames() --Get a list of all the peripherals
  34.   log("Peripherals:")
  35.   for _, pSide in ipairs(peripherals) do
  36.     local pType = peripheral.getType(pSide)
  37.     local pFunctions = peripheral.wrap(pSide)
  38.    
  39.     if(pType == "BigReactors-Reactor") then --If we found a reactor
  40.       table.insert(reactors, pSide)
  41.     elseif (pType == "BigReactors-Turbine") then
  42.       table.insert(turbines, pSide)
  43.     elseif (pType == "monitor") then
  44.       table.insert(monitors, pSide)
  45.     end
  46.   end
  47. end
  48.  
  49. --Lists all of the peripherals connected
  50. function listPeripherals()
  51.   log("Reactors:")
  52.   for i, pSide in ipairs(reactors) do
  53.     log("\t" ..i.. ":\t" ..pSide)
  54.   end
  55.  
  56.   log("Turbines:")
  57.   for i, pSide in ipairs(turbines) do
  58.     log("\t" ..i.. ":\t" ..pSide)
  59.   end
  60.  
  61.   log("Monitors:")
  62.   for i, pSide in ipairs(monitors) do
  63.     log("\t" ..i.. ":\t" ..pSide)
  64.   end
  65. end
  66.  
  67.  
  68. --Updates all info on screen
  69. function update()
  70.   --Clear the window(s)
  71.   clear()
  72.   log("Test output")
  73.   local x,y = term.getCursorPos()
  74.   log("Cursor pos: " ..x.. " " ..y)
  75. end
  76.  
  77. log ("Turbine max energy: " ..turbineMaxEnergy)
  78. log ("Reactor max temp:" ..reactorMaxTemp)
  79.  
  80. updatePeripherals()
  81. --listPeripherals()
  82. sleep(1)
  83. while true do
  84.   update()
  85.   sleep(0.5)
  86. end
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top