Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component = require("component")
- term = require("term")
- gpu = component.gpu
- event = require("event")
- sides = require("sides")
- mfsu = component.ic2_te_mfsu
- redstone = component.proxy(component.get("687c5bc1-1a41-4930-9a1c-a7d1af612a5b"))
- reactor = component.proxy(component.get("e4b738c2-b758-495f-899e-39e6114ff2b3"))
- 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 }
- ------------------------------------------------------------------------------------------------------------------
- --[[ VARIABLES ]]--
- ------------------------------------------------------------------------------------------------------------------
- Border_bg = colors.diamond
- Default_bg = colors.gray
- text_col = colors.blue
- status_col = colors.black
- barBack = colors.black
- barFill = colors.white
- header = colors.orange
- Side = sides.east
- -----------------------------------------------------------------------------------------------------------------
- --[[ FUNCTIONS ]]--
- ------------------------------------------------------------------------------------------------------------------
- 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 dot(n)
- local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
- return left..(num:reverse():gsub('(%d%d%d)','%1.'):reverse())..right
- 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," ")
- guiBorders(1,5,w,1," ")
- for i = 1,h do
- guiBorders(1,i,1,1," ")
- guiBorders(w,i,1,1," ")
- end
- for i = 5,h do
- guiBorders(7,i,1,5," ")
- end
- for i = 5,h do
- guiBorders(w-6, i,1,5," ")
- end
- guiBorders(1,h,w,1," ")
- gpu.setForeground(header)
- Center(3,"--[[ Nuclear Reactor Control ]]--")
- end
- function key()
- -- KEYS --
- gpu.set(25, 14, "lol")
- gpu.setBackground(colors.red)
- gpu.fill(16,14,8,3," ")
- gpu.setBackground(Default_bg)
- end
- function drawBarPos(xOff,yOff,w,h,percentage,text)
- barLen = math.floor(percentage*(h-2) +0.5)
- gpu.setForeground(barBack)
- gpu.fill(xOff,yOff,w,h,"█")
- gpu.setForeground(barFill)
- gpu.fill(xOff+1,yOff+1,w-2,h-2,"█")
- if percentage >= 0.75 then
- gpu.setForeground(colors.green)
- elseif percentage >= 0.5 then
- gpu.setForeground(colors.yellow)
- elseif percentage >= 0.25 then
- gpu.setForeground(colors.orange)
- elseif percentage >= 0 then
- gpu.setForeground(colors.red)
- end
- gpu.fill(xOff+1,(yOff+h-1)-barLen,w-2,barLen,"█")
- gpu.setForeground(colors.white)
- gpu.set(xOff,h+6,"%"..math.floor(percentage*100).." ")
- gpu.set(xOff, h+7, text)
- end
- function drawBarNeg(xOff,yOff,w,h,percentage, text)
- barLen = math.floor(percentage*(h-2) +0.5)
- gpu.setForeground(barBack)
- gpu.fill(xOff,yOff,w,h,"█")
- gpu.setForeground(barFill)
- gpu.fill(xOff+1,yOff+1,w-2,h-2,"█")
- if percentage >= 0.75 then
- gpu.setForeground(colors.red)
- elseif percentage >= 0.5 then
- gpu.setForeground(colors.orange)
- elseif percentage >= 0.25 then
- gpu.setForeground(colors.yellow)
- elseif percentage >= 0 then
- gpu.setForeground(colors.green)
- end
- gpu.fill(xOff+1,(yOff+h-1)-barLen,w-2,barLen,"█")
- gpu.setForeground(colors.white)
- gpu.set(xOff+1,h+6,"%"..math.floor(percentage*100).." ")
- gpu.set(xOff, h+7, text)
- end
- function Center(y, text)
- w, h = gpu.getResolution()
- term.setCursor((w-string.len(text))/2+1, y)
- term.write(text)
- end
- function InfoUpdate(y, text) -- Text for function UPDATE
- w, h = gpu.getResolution()
- place = (w-string.len(text))-7
- gpu.set(place, y, text)
- end
- function Display()
- w, h = gpu.getResolution()
- gpu.set(9,6,"Reactor Status:")
- InfoUpdate(6," "..tostring(stat))
- gpu.set(9,8, "Heat: ")
- InfoUpdate(8, tostring(heat).." C")
- gpu.set(9,10, "EU/T: ")
- InfoUpdate(10, " "..tostring(out))
- gpu.set(9,12, "Stored EU: ")
- InfoUpdate(12," ".. dot(tostring(math.floor(stored))).."/"..dot(tostring(math.floor(mfsu.getCapacity()))))
- end
- function addButton(x, y, col,text)
- leng = string.len(text)
- gpu.setBackground(col)
- gpu.fill(x, y, (leng + 2), 3," ")
- gpu.setForeground(status_col)
- gpu.set(x+1, y+1, text)
- gpu.setBackground(Default_bg)
- end
- function fail()
- if heatPerc*100 >= 20 then
- redstone.setOutput(Side, 0)
- end
- end
- gpu.setResolution(60,20)
- GUI()
- --key()
- addButton(19,16, colors.red,"Offline")
- addButton(34,16, colors.lime,"Online")
- function getP()
- if x~= nil and y ~= nil then
- if x >= 19 and x<=25 and y >= 16 and y <= 18 then
- redstone.setOutput(Side, 0)
- elseif x >= 34 and x <= 42 and y >= 16 and y <= 18 then
- redstone.setOutput(Side, 15)
- end
- end
- end
- while true do
- -- Update
- if reactor.producesEnergy() then
- stat = "Active"
- else
- stat = "Offline"
- end
- --Updates
- stored = mfsu.getEnergy()
- heat = reactor.getHeat()
- out = reactor.getReactorEUOutput()
- EOut = reactor. getReactorEnergyOutput()
- -- Percs
- heatPerc = reactor.getHeat() / reactor.getMaxHeat()
- mfsuPerc = mfsu.getEnergy() / mfsu.getCapacity()
- -- Bars
- drawBarNeg(2,6,5,12, heatPerc, "Heat")
- drawBarPos(55,6,5,12, mfsuPerc,"Mfsu")
- -- Functions
- Display()
- fail()
- _,_,x,y = event.pull(1, "touch")
- getP()
- --os.sleep(.2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement