Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Reactors Control Program for Opencomputers
- requires tier 3 computer, graphics card and screens.
- mekanism support includes induction matrix, industrial turbine, laser amplifier, and fusion reactor. currently supports only 1
- industrial turbine. redstone I/O needs to be below the laser amplifier with a redstone sensitive energy cable below it.
- big reactors support is only for passive cooled reactors currently. turbine support is planned in the near future.
- multi turbine support is planned for both big reactors and mekanism. should be implemented soon-ish.
- By Tacnuke2011
- Thx to MalkContent for helping figure out my recursive nightmare!]]
- --libs
- local component = require("component")
- local term = require("term")
- local event = require("event")
- local seri = require("serialization")
- local colors = require("colors")
- local sides = require("sides")
- --vars
- local listen = true
- local br = component.getPrimary("br_reactor")
- local ec = component.getPrimary("elite_energy_cube")
- --local iT = component.industrial_turbine
- --local lasAmp = component.laser_amplifier
- --local rla = component.reactor_logic_adapter
- --local rs = component.redstone
- local gpu = component.getPrimary("gpu")
- local w, h = gpu.getResolution()
- local run = true
- local enCap = br.getEnergyCapacity()
- local enStor = "..."
- local storDev = "..."
- local on = .2 -- lower limit i.e. .2 is 20%
- local off = .85 -- upper limit i.e. .85 is 85%
- local enProd = ""
- local enGen = ""
- --local im = component.getPrimary("induction_matrix")
- --energy check
- local function power()
- local temEn = ""
- local maxEn = ""
- if ec then
- maxEn = ec.getMaxEnergy()
- temEn = ec.getEnergyStored()
- elseif im then
- maxEn = im.getMaxEnergy()
- temEn = im.getEnergyStored()
- elseif not ec and not im then
- maxEn = br.getEnergyCapacity()
- temEn = br.getEnergyStored()
- end
- -- if lasAmp.getEnergy() == lasAmp.getMaxEnergy() then
- -- rs.setOutput(sides.bottom, 15)
- -- elseif lasAmp.getEnergy() ~= lasAmp.getMaxEnergy() then
- -- rs.setOutput(sides.bottom, 0)
- -- end
- if rla then
- gpu.set(1, 1, "Fusion Reactor detected")
- os.sleep(.5)
- if rla.getWater() and rla.hasFuel() then
- if rla.getInjectionRate() ~= 4 then
- rla.setInjectionRate(4)
- end
- elseif not rla.getWater() then
- rla.setInectionRate(2)
- end
- elseif not rla then
- gpu.set(1, 1, "Big Reactor detected")
- --os.sleep(.5)
- end
- if not ec then
- temEn = im.getEnergyStored()
- enMin = (maxEn*on)
- enMax = (maxEn*off)
- enStor= math.floor((temEn/maxEn)*100)
- storDev = "Induction Matrix: "
- if iT then
- turSt = iT.getSteam()
- turPow = iT.getEnergyStored()
- enProd = math.floor(im.getInput()/2.5)
- enGen = "Indutrial Turbine "
- end
- elseif br and not ec then
- enGen = "Big Reactor "
- enProd = math.floor(br.getEnergyProducedLastTick())
- temEn = br.getEnergyStored()
- enMin = (br.getEnergyCapacity()*on)
- enMax = (br.getEnergyCapacity()*off)
- enStor= math.floor((temEn/enCap)*100)
- storDev = "Reactor: "
- enGen = "Big Reactor"
- enProd = math.floor(br.getEnergyProducedLastTick())
- elseif ec then
- temEn = ec.getEnergyStored()
- storDev = "Energy Cube: "
- enGen = "Big Reactor"
- enProd = math.floor(br.getEnergyProducedLastTick())
- enStor = (temEn/ec.getMaxEnergyStored()*100)
- enMin = (ec.getMaxEnergy()*on)
- enMax = (ec.getMaxEnergy()*off)
- end
- if temEn <= enMin then br.setActive(true)
- elseif temEn >= enMax then br.setActive(false)
- end
- end
- --display settings and output
- local function heading(text)
- w, h = gpu.getResolution()
- term.setCursor((w-string.len(text))/2+4, 2)
- term.write(text)
- end
- local function display()
- gpu.setBackground(0x000000)
- gpu.setResolution(140, 40)
- gpu.setForeground(0x0040ff)
- gpu.fill(1, 1, 40, h," ")
- power()
- end
- local function stat()
- if br.getActive() then
- gpu.setForeground(0x000000)
- gpu.setBackground(0x00a500)
- gpu.fill(83, 10, 7, 1, "online")
- gpu.set(83, 10, "Online")
- gpu.setBackground(0xff0000)
- gpu.fill(75, 10, 7, 1, "offline")
- gpu.set(75, 10, "Offline")
- elseif not br.getActive() then
- gpu.setForeground(0x000000)
- gpu.setBackground(0xff0000)
- gpu.fill(83, 10, 7, 1, "online")
- gpu.set(83, 10, "Online")
- gpu.setBackground(0x00a500)
- gpu.fill(75, 10, 7, 1, "offline")
- gpu.set(75, 10, "Offline")
- end
- end
- local function info()
- gpu.setForeground(0x0040ff)
- gpu.setBackground(0x000000)
- gpu.set(((w-string.len("Reactor Status:"))/2-2), 10, "Reactor Status:")
- gpu.fill(1, 11, w, 1, " ")
- gpu.set(((w-string.len("Fuel Consumption:"))/2-3), 11, "Fuel Consumption: "..tonumber(string.format("%.3f", br.getFuelConsumedLastTick())).." mB/t")
- gpu.fill(w, 12, w, 1, " ")
- gpu.set(((w-string.len("Fuel Amount"))/2-1), 12, "Fuel Amount: "..br.getFuelAmount().." mB")
- gpu.fill(1, 13, w, 1, " ")
- gpu.set(((w-string.len("Waste Amount: "))/2-1), 13, "Waste Amount: "..br.getWasteAmount().." mB")
- gpu.fill(1, 14, w, 1, " ")
- gpu.set(((w-string.len(storDev))/2.0125), 14, storDev..enStor.." %")
- gpu.fill(1, 15, w, 1, " ")
- gpu.set(((w-string.len("RF Output: "))/2+1), 15, "RF Output: "..(ec.getEnergy()/ec.getEnergyStored()).." kRF/t")
- gpu.fill(1, 16, w, 1, " ")
- gpu.set(((w-string.len("RF Production: "))/2-1), 16, "RF Production: "..enGen..": "..enProd.." RF/t")
- gpu.fill(1, 17, w, 1, " ")
- gpu.set(((w-string.len("Casing Temp.: "))/2-1), 17, "Casing Temp.: "..math.floor(br.getCasingTemperature()).." C")
- gpu.fill(1, 18, w, 1, " ")
- gpu.set(((w-string.len("Fuel Temp.: "))/2), 18, "Fuel Temp.: "..math.floor(br.getFuelTemperature()).." C")
- gpu.set(((w-string.len("Fuel Reactivity: "))/2-2), 19, "Fuel Reactivity: "..math.floor(br.getFuelReactivity()).." %")
- gpu.setBackground(0x00a500)
- gpu.setForeground(0x000000)
- gpu.set(((w-string.len("Exit"))/2+1), 21, "Exit")
- gpu.setBackground(0x000000)
- gpu.setForeground(0x0040ff)
- os.sleep(3)
- display()
- end
- --event listener
- --exit button
- function listen(name, address, x, y, button, player)
- if x <=74 and x >= 69 and y == 21 then
- term.setCursor(1, 1)
- term.clear()
- br.setActive(false)
- run = false
- term.write("Closing")
- os.sleep(.5)
- gpu.setBackground(0x000000)
- term.setCursor(1,1)
- term.clear()
- elseif x >= 82 and x <= 91 and y == 10 then
- br.setActive(true)
- elseif x >= 74 and x <= 82 and y == 10 then
- br.setActive(false)
- end
- end
- event.listen("touch", listen)
- --main loop
- while run do
- heading("Reactor Control")
- stat()
- info()
- os.sleep(1)
- end
- event.ignore("touch", listen)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement