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
- function wrapreactor()
- --wrap reactor peripheral
- reactor = peripheral.wrap("back")
- reactor.setActive(true)
- end
- function wrapmonitor()
- --applicable monitor variables
- monitor = peripheral.wrap("right")
- monitor.write("System Initialized")
- width, height = monitor.getSize()
- end
- function wrapmodem()
- --applicable modem variables
- modem = peripheral.wrap("top")
- -- modem.transmit(401, 1, "Big Reactor Manager initializing")
- end
- function configvars()
- pullInfo()
- rods = 99
- 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()
- end
- function sendmodeminfo()
- modem.transmit(401, 2, temp)
- modem.transmit(402, 3, energy)
- modem.transmit(403, 4, lastTick)
- end
- function getmodeminfo()
- modem.open(400)--Open channel 400 so that we can listen on it : Reactor Temperature
- local event400, modemSide400, senderChannel400, replyChannel400, Message400, senderDistance400 = os.pullEvent("modem_message")
- modem.open(401)--Open channel 401 so that we can listen on it : Reactor Stored Energy
- local event401, modemSide401, senderChannel401, replyChannel401, Message401, senderDistance401 = os.pullEvent("modem_message")
- modem.open(402)--Open channel 402 so that we can listen on it : Reactor Produced Energy
- local event402, modemSide402, senderChannel402, replyChannel402, Message402, senderDistance402 = os.pullEvent("modem_message")
- modem.open(403)--Open channel 403 so that we can listen on it : : Reactor Control Rod Level
- local event403, modemSide403, senderChannel403, replyChannel403, Message403, senderDistance403 = os.pullEvent("modem_message")
- modem.close(400)
- modem.close(401)
- modem.close(402)
- modem.close(403)
- 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(" Cel. ")
- 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(ReactorCRL)
- 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() < energy) and (energy < target) then
- decrods()
- end
- -- if energy is increasing and storage is over half insert rods by 1%
- if (reactor.getEnergyStored() > energy) and (energy > target) then
- incrods()
- end
- if (reactor.getEnergyStored() == 0) then
- decrods()
- end
- end
- function main()
- while (true) do
- -- pullInfo()
- -- sendmodeminfo()
- getmodeminfo()
- sleep(1)
- displayStats()
- -- rodManagement()
- sleep(1)
- end
- end
- --wrapreactor()
- wrapmonitor()
- wrapmodem()
- --configvars()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement