Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component = require("component")
- reactor = component.br_reactor
- event = require("event")
- term = require("term")
- gpu = component.gpu
- event = require("event")
- keyboard = require("keyboard")
- ------------------
- -- Color table --
- colors = { black = 0x000000, white = 0xf8f8ff, blue = 0x0000ff, lightGray = 0xd9d9d9, red = 0xff0000,
- purple = 0x9b30ff, carrot = 0xffa500, magenta = 0xcd00cd, lightBlue = 0x87cefa, yellow = 0xffff00,
- lime = 0x32cd32, pink = 0xffc0cb, gray = 0x696969, brown = 0x8b4500, green = 0x006400, cyan = 0x008b8b,
- olive = 0x6b8e23, gold = 0x8b6914, orangered = 0xdb4e02, diamond = 0x0fa7c7,crimson = 0xaf002a,fuchsia = 0xfd3f92,
- folly = 0xff004f, frenchBlue = 0x0072bb, lilac = 0x86608e, flax = 0xeedc82, darkGray = 0x563c5c,
- englishGreen = 0x1b4d3e, eggplant = 0x614051, deepPink = 0xff1493, ruby = 0x843f5b, orange = 0xf5c71a,
- lemon = 0xffd300, darkBlue = 0x002e63, bitterLime = 0xbfff00 }
- -------------------------
- -- Settings for screen --
- --gpu.setBackground(colors.black)
- --gpu.setForeground(colors.orange)
- gpu.setResolution(50,20)
- term.clear()
- -------------------------
- --Vars --
- auto = false
- numm = 100
- targetP = 30 -- This is the target percentage the computer will strive for to keep in the reactor
- Border_bg = colors.white
- Default_bg = colors.gray
- text_col = colors.white
- status_col = colors.black
- type = nil
- AutoSteam = false
- targetSteam = 2000
- ------------------------------------------------------------------------------------------------------------------
- --[[ FUNCTIONS ]]--
- ------------------------------------------------------------------------------------------------------------------
- DisplayGeneration = {
- [3] = "Reactor type....: ",
- [4] = "RF Production...: ",
- [5] = "RF Stored.......: ",
- [6] = "Fuel use........: "
- }
- DisplaySteam = {
- [3] = "Reactor Type....:",
- [4] = "Water Amount....:",
- [5] = "Steam Amount....:",
- [6] = "Steam Per Tick..:",
- [7] = "Fuel use........:",
- [8] = "Temperature.....:"
- }
- function guiBorders(x,y,len,height,str) -- BORDER FUNC FOR GUI
- gpu.setBackground(Border_bg)
- gpu.fill(x,y,len,height,str)
- gpu.setBackground(Default_bg)
- end
- function GUI() -- SETS THE GUI LAYOUT (GRAPHICAL USER INTERFACE)
- gpu.setBackground(Default_bg)
- term.clear()
- w, h = gpu.getResolution()
- guiBorders(1,1,w,1," ")
- for i = 1,h do
- guiBorders(1,i,1,1," ")
- guiBorders(w,i,1,1," ")
- end
- guiBorders(1,h,w,1," ")
- gpu.setForeground(text_col)
- end
- function Center(y,text) -- CENTERS TEXT
- w, h = gpu.getResolution()
- term.setCursor((w-string.len(text))/2+1, y)
- term.write(text)
- end
- function getType()
- if reactor.isActivelyCooled() == true then
- type = true
- else
- type = false
- end
- end
- function info(y,title) -- Rewriting of gpu.set
- gpu.set(2,y,title)
- end
- function displayGen()
- Center(2,"Reactor Info")
- Center(10, "On - Off - Auto")
- term.setCursor(3,2)
- for k,v in pairs(DisplayGeneration) do
- info(k,v)
- end
- end
- function displaySteam()
- Center(2,"Reactor Info")
- Center(10, "On - Off - Auto")
- term.setCursor(3,2)
- for k,v in pairs(DisplaySteam) do
- info(k,v)
- end
- end
- function infoUpdate(y, text) -- Text for function UPDATE
- w, h = gpu.getResolution()
- place = (w-string.len(text))-2
- gpu.set(place, y, text)
- end
- function UpdateGen()
- RP = math.floor((reactor.getEnergyStored()/reactor.getEnergyCapacity()*100))
- if type == false then
- infoUpdate(3, "Passive")
- infoUpdate(4, " "..gen .." RF/T")
- infoUpdate(5, " "..stored .."/".. maxRF .."(".. RP .."%) RF")
- infoUpdate(6, " "..FuelConsumption .." mB")
- else
- infoUpdate(3, "Active")
- infoUpdate(4, " ".. water .." mB")
- infoUpdate(5, " ".. STEAM .." mB")
- infoUpdate(6, " ".. steamGen .." mB/t")
- infoUpdate(7, " ".. FuelConsumption .." mb")
- infoUpdate(8, " ".. math.floor(reactor.getCasingTemperature()+0.5) .." C")
- end
- end
- function autoGen()
- if auto == true then
- if reactor.getEnergyStored() >= (reactor.getEnergyCapacity() / 100 * 10) then
- reactor.setAllControlRodLevels(100)
- stat = false
- numm = 100
- elseif reactor.getEnergyStored() <= (reactor.getEnergyCapacity()/100 * 5) then
- startinit()
- reactor.setAllControlRodLevels(numm)
- stat = true
- elseif reactor.getEnergyStored() <= (reactor.getEnergyCapacity()/100 * 2) then
- reactor.setAllControlRodLevels(0)
- stat = true
- end
- end
- end
- function autoSteam()
- if AutoSteam == true then
- -- Adjust Rods here till it makes 2k mb/t, or target Steam.
- if reactor.getHotFluidProducedLastTick() <= tonumber(targetSteam) then
- startinit()
- reactor.setAllControlRodLevels(numm)
- end
- elseif AutoSteam == false then
- -- Set To manual mode.
- end
- end
- function ButtonPress()
- if type == true then -- Actively Cooled Reactor button part
- if x ~= nil and y ~= nil then
- if x >= 17 and x <= 20 and y == 10 then
- gpu.setBackground(status_col)
- gpu.set(17, 10, " On ")
- reactor.setAllControlRodLevels(0)
- gpu.setBackground(Default_bg)
- gpu.set(21,10, "- Off - Auto ")
- elseif x >= 22 and x <= 26 and y == 10 then
- gpu.setBackground(status_col)
- gpu.set(22, 10, " Off ")
- reactor.setAllControlRodLevels(100)
- AutoSteam = false
- gpu.setBackground(Default_bg)
- gpu.set(17,10, " On -")
- gpu.setBackground(Default_bg)
- gpu.set(27,10,"- Auto ")
- elseif x >= 28 and x <= 33 and y == 10 then
- gpu.setBackground(status_col)
- gpu.set(28,10," Auto ")
- AutoSteam = true
- gpu.setBackground(Default_bg)
- gpu.set(17, 10, " On - Off -")
- end
- end
- elseif type == false then
- if x ~= nil and y ~= nil then
- if x >= 17 and x <= 20 and y == 10 then
- gpu.setBackground(status_col)
- gpu.set(17, 10, " On ")
- reactor.setAllControlRodLevels(0)
- gpu.setBackground(Default_bg)
- gpu.set(21,10, "- Off - Auto ")
- elseif x >= 22 and x <= 26 and y == 10 then
- gpu.setBackground(status_col)
- gpu.set(22, 10, " Off ")
- reactor.setAllControlRodLevels(100)
- auto = false
- gpu.setBackground(Default_bg)
- gpu.set(17,10, " On -")
- gpu.setBackground(Default_bg)
- gpu.set(27,10,"- Auto ")
- elseif x >= 28 and x <= 33 and y == 10 then
- gpu.setBackground(status_col)
- gpu.set(28,10," Auto ")
- auto = true
- gpu.setBackground(Default_bg)
- gpu.set(17, 10, " On - Off -")
- end
- end
- end
- end
- function check()
- if type == true then
- term.clear()
- displaySteam()
- else
- term.clear()
- displayGen()
- end
- end
- function startinit()
- os.sleep(.3)
- numm = numm - 5
- end
- ------------------------
- -- Main Loop --
- getType()
- term.clear()
- GUI()
- if type == false then
- displayGen()
- else
- displaySteam()
- end
- while true do
- -- Updating vars --
- -- Generation --
- gen = string.format("%.2f", reactor.getEnergyProducedLastTick())
- stored = reactor.getEnergyStored()
- maxRF = reactor.getEnergyCapacity()
- -----------------
- -- Steam --
- STEAM = string.format("%.2f", reactor.getHotFluidAmount())
- steamGen = string.format("%.2f", reactor.getHotFluidProducedLastTick())
- water = string.format("%.2f", reactor.getCoolantAmount())
- ----------------
- -- Standard info --
- FuelConsumption = string.format("%.2f", reactor.getFuelConsumedLastTick())
- ------------------
- -- check()
- UpdateGen()
- autoGen()
- autoSteam()
- _,_,x,y = event.pull(1, "touch")
- ButtonPress()
- if keyboard.isKeyDown(keyboard.keys.w) and keyboard.isControlDown() then
- term.clear()
- w,h = gpu.maxResolution()
- gpu.setResolution(w,h)
- os.exit()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement