Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Loepie78s Big Reactor Manager v0.1 based on :
- --FusionNrg's Big Reactor Manager v1.1
- --With wireless
- --last revised 22-2-2014
- -- designed for reactor to rear of computer with at least a 2x3 monitor on the top of the computer
- -- if you want to use this script for multiple reactors, make sure you change the
- -- function sendmodeminfo for different modem channels
- -- version 201402221241
- function wrapreactor()
- --wrap reactor peripheral
- reactor = peripheral.wrap("back")
- reactor.setActive(true)
- end
- function wrapmonitor()
- --applicable monitor variables
- monitor = peripheral.wrap("top")
- monitor.clear()
- monitor.write("System Initialized")
- width, height = monitor.getSize()
- end
- function wrapmodem()
- --applicable modem variables
- modem = peripheral.wrap("left")
- end
- function configvars()
- rods = 0 --max means no RF being generated
- target = 8000000 -- adjustable between 0 and 10 million depending how much you want on hand
- full = 10000000 -- full buffer size
- end
- function pullInfo()-- pulling the latest from the reactor
- if reactor.getConnected() then
- if reactor.getActive() then
- ReactorStatus = "Active"
- ReactorTemp = reactor.getTemperature()
- ReactorES = math.floor(((reactor.getEnergyStored()/full) * 100) + 0.5)
- ReactorMath = reactor.getEnergyStored()
- ReactorLT = math.floor(reactor.getEnergyProducedLastTick() + 0.5)
- ReactorCRL = rods
- else
- ReactorStatus = "Offline"
- ReactorTemp = reactor.getTemperature()
- ReactorES = math.floor(((reactor.getEnergyStored()/full) * 100) + 0.5)
- ReactorMath = reactor.getEnergyStored()
- ReactorLT = math.floor(reactor.getEnergyProducedLastTick() + 0.5)
- ReactorCRL = rods
- end
- else
- ReactorStatus = "Build Incomplete"
- ReactorTemp = "NoTemp"
- ReactorES = "NoBuffer"
- ReactorMath = 0
- ReactorLT = "NoLastTick"
- ReactorCRL = "NoRodControl"
- end
- end
- function sendmodeminfo()
- modem.transmit(600, 3, ReactorStatus)
- modem.transmit(601, 3, ReactorTemp)
- modem.transmit(602, 3, ReactorES)
- modem.transmit(603, 3, ReactorLT)
- modem.transmit(604, 3, ReactorCRL)
- end
- function displayStats() -- display stats to the monitor in 2 columns
- --wrap monitor and pull sizing
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("Temp")
- monitor.setCursorPos(width / 2, 1)
- monitor.write("Buffer")
- monitor.setCursorPos(1, 2)
- monitor.write(ReactorTemp)
- monitor.write(" Celc. ")
- monitor.setCursorPos(width / 2, 2)
- -- monitor.write(math.floor(((ReactorES/full) * 100) + 0.5))
- monitor.write(ReactorES)
- monitor.write(" %")
- monitor.setCursorPos(1, 4)
- monitor.write("Energy Last Tick: ")
- monitor.setCursorPos(1, 5)
- -- monitor.write(math.floor(ReactorLT+ 0.5))
- monitor.write(ReactorLT)
- monitor.write()
- monitor.write("RF/t")
- monitor.setCursorPos(1, 7)
- monitor.write("Rod Insertion")
- monitor.setCursorPos(1, 8)
- monitor.write(rods)
- monitor.write(" %")
- end
- function decrods()
- rods=rods-1
- if (rods < 0) then
- rods=0
- end
- reactor.setAllControlRodLevels(rods)
- end
- function incrods()
- rods=rods+1
- if (rods > 100) then
- rods=100
- end
- reactor.setAllControlRodLevels(rods)
- end
- function rodManagement()
- --if we're losing energy and below half or empty... pull rods out by 1%
- if (reactor.getEnergyStored() < ReactorMath) and (ReactorMath < target) then
- decrods()
- end
- -- if energy is increasing and storage is over half insert rods by 1%
- if (reactor.getEnergyStored() > ReactorMath) and (ReactorMath > target) then
- incrods()
- end
- if (reactor.getEnergyStored() == 0) then
- decrods()
- end
- end
- function main()
- while (true) do
- pullInfo()
- sendmodeminfo()
- sleep(1)
- displayStats()
- rodManagement()
- sleep(1)
- end
- end
- function waitDelay()
- sleep(10)
- end
- waitDelay()
- wrapreactor()
- wrapmonitor()
- configvars()
- wrapmodem()
- main()
Advertisement
Add Comment
Please, Sign In to add comment