Advertisement
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 2-6-2014
- -- designed for reactor to rear of computer with at least a 2x3 monitor on the top of the computer
- -- version 201402090006
- function wrapreactor()
- --wrap reactor peripheral
- reactor = peripheral.wrap("back")
- reactor.setActive(true)
- end
- function wrapmonitor()
- --applicable monitor variables
- monitor = peripheral.wrap("top")
- monitor.write("System Initialized")
- width, height = monitor.getSize()
- end
- function wrapmodem()
- --applicable modem variables
- modem = peripheral.wrap("left")
- end
- function configvars()
- pullInfo()
- rods = 99 --max means no RF being generated
- target = 5000000 -- 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
- ReactorTemp = reactor.getTemperature()
- ReactorES = reactor.getEnergyStored()
- ReactorLT = reactor.getEnergyProducedLastTick()
- -- ReactorCRL = reactor.getControlRodLevel()
- ReactorCRL = rods
- end
- function sendmodeminfo()
- modem.transmit(400, 1, reactor.getActive())
- modem.transmit(401, 1, ReactorTemp)
- modem.transmit(402, 1, ReactorES)
- modem.transmit(403, 1, ReactorLT)
- modem.transmit(404, 1, 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(" %")
- monitor.setCursorPos(1, 4)
- monitor.write("Energy Last Tick: ")
- monitor.setCursorPos(1, 5)
- monitor.write(math.floor(ReactorLT+ 0.5))
- 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() < ReactorES) and (ReactorES < target) then
- decrods()
- end
- -- if energy is increasing and storage is over half insert rods by 1%
- if (reactor.getEnergyStored() > ReactorES) and (ReactorES > 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
- wrapreactor()
- wrapmonitor()
- configvars()
- wrapmodem()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement