Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Reactor and turbine control script by EternalClickbait
- --Reactor, turbine and monitor must be connected with wired modems to the computer
- local reactors = {}
- local turbines = {}
- local monitors = {}
- --The maximum temperature for the reactor
- local reactorMaxTemp = 200
- --The maximum energy in our turbine's buffer. Max is 1M (1,000,000)
- local turbineMaxEnergy = 500000
- --Prints a message to all monitors/windows
- function log(message)
- print(message)
- for _, side in ipairs(monitors) do
- peripheral.wrap(side).write(message)
- end
- end
- --Sets the scales on all monitors for easily visible text
- function setMonitorScales(scale)
- for _, side in ipairs(monitors) do
- local m = peripheral.wrap(side)
- --Get the normalized scale for the monitor (1 = 1 block)
- local x,y = m.getSize()
- local avg = (x+y)/2
- m.setTextScale(tonumber(scale) * avg)
- end
- end
- --Clears all monitors/windows
- function clear()
- term.clear()
- for _, side in ipairs(monitors) do
- peripheral.wrap(side).clear()
- peripheral.wrap(side).setCursorPos(1,1)--Reset the cursor position
- end
- term.setCursorPos(1,1)
- end
- --Updates the list of reactors, turbines and monitor
- function updatePeripherals()
- local peripherals = peripheral.getNames() --Get a list of all the peripherals
- log("Peripherals:")
- for _, pSide in ipairs(peripherals) do
- local pType = peripheral.getType(pSide)
- local pFunctions = peripheral.wrap(pSide)
- if(pType == "BigReactors-Reactor") then --If we found a reactor
- table.insert(reactors, pSide)
- elseif (pType == "BigReactors-Turbine") then
- table.insert(turbines, pSide)
- elseif (pType == "monitor") then
- table.insert(monitors, pSide)
- end
- end
- end
- --Lists all of the peripherals connected
- function listPeripherals()
- log("Reactors:")
- for i, pSide in ipairs(reactors) do
- log("\t" ..i.. ":\t" ..pSide)
- end
- log("Turbines:")
- for i, pSide in ipairs(turbines) do
- log("\t" ..i.. ":\t" ..pSide)
- end
- log("Monitors:")
- for i, pSide in ipairs(monitors) do
- log("\t" ..i.. ":\t" ..pSide)
- end
- end
- --Updates all info on screen
- function update()
- --Clear the window(s)
- clear()
- end
- log ("Turbine max energy: " ..turbineMaxEnergy)
- log ("Reactor max temp:" ..reactorMaxTemp)
- updatePeripherals()
- listPeripherals()
- sleep(2)
- local i = 0.5
- while true do
- update()
- setMonitorScales(i)
- log("Current scale: " ..i)
- i = i +0.5
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement