Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local c = component.computer
- local cell = component.getPrimary("draconic_rf_storage")
- local gpu = component.gpu
- local colors = require("colors")
- local term = require("term")
- local event = require("event")
- local thread = require("thread")
- local width, height = gpu.getResolution()
- loopActive = true
- local userInputThread = thread.create(function()
- while true do
- if event.pull("touch") then
- loopActive = false
- gpu.setBackground(0x000000)
- gpu.setForeground(0xFFFFFF)
- os.sleep(0.01)
- gpu.fill(1,1,width,height," ")
- term.setCursor(1,1)
- os.exit()
- end
- end
- end)
- local powerLowAlert = thread.create(function()
- while loopActive do
- if ((cell.getEnergyStored()/cell.getMaxEnergyStored())*100)<5 then
- c.beep(500,0.1)
- os.sleep(0.4)
- end
- os.sleep(0.1)
- end
- end)
- local function cls()
- gpu.fill(1,1,width,height," ")
- end
- local function bgColor(color)
- if color == 'black' then
- gpu.setBackground(0x000000)
- end
- if color == 'darkgray' then
- gpu.setBackground(0x444444)
- end
- if color == 'gray' then
- gpu.setBackground(0x888888)
- end
- if color == 'lightgray' then
- gpu.setBackground(0xBBBBBB)
- end
- if color == 'white' then
- gpu.setBackground(0xFFFFFF)
- end
- if color == 'red' then
- gpu.setBackground(0xFF0000)
- end
- if color == 'green' then
- gpu.setBackground(0x00FF00)
- end
- if color == 'blue' then
- gpu.setBackground(0x0000FF)
- end
- if color == 'yellow' then
- gpu.setBackground(0xFFFF00)
- end
- if color == 'violet' then
- gpu.setBackground(0xFF00FF)
- end
- if color == 'aqua' then
- gpu.setBackground(0x00FFFF)
- end
- if color == 'orange' then
- gpu.setBackground(0xFF8800)
- end
- if color == 'pink' then
- gpu.setBackground(0xFF88FF)
- end
- if color == 'brown' then
- gpu.setBackground(0x884400)
- end
- if color == 'darkgreen' then
- gpu.setBackground(0x008800)
- end
- if color == 'purple' then
- gpu.setBackground(0x990099)
- end
- end
- local function fgColor(color)
- prevColor = gpu.getBackground()
- bgColor(color)
- gpu.setForeground(gpu.getBackground())
- gpu.setBackground(prevColor)
- end
- local function draw(x,y,a,b)
- gpu.fill(x,y,a,b," ")
- end
- local function colorDraw(x,y,a,b,color)
- prevColor = gpu.getBackground()
- bgColor(color)
- gpu.fill(x,y,a,b," ")
- gpu.setBackground(prevColor)
- end
- local function text(x,y,text)
- term.setCursor(x,y)
- print(text)
- end
- local function colorText(x,y,text,bColor,fColor)
- prevBgColor = gpu.getBackground()
- prevFgColor = gpu.getForeground()
- bgColor(fColor)
- gpu.setForeground(gpu.getBackground())
- bgColor(bColor)
- term.setCursor(x,y)
- print(text)
- gpu.setBackground(prevBgColor)
- gpu.setForeground(prevFgColor)
- end
- cls()
- text(1,1,"Damckell Graphical Interface; DGI")
- os.sleep(1.25)
- text(1,2,"DGI Initialized")
- os.sleep(0.01)
- text(1,3,"Click to exit")
- os.sleep(0.5)
- local function getEnergyPercent()
- return math.floor(cell.getEnergyStored()/cell.getMaxEnergyStored()*100)
- end
- local function getEnergy()
- return cell.getEnergyStored()
- end
- local function getMaxEnergy()
- return cell.getMaxEnergyStored()
- end
- colorDraw(1,1,width,5,'gray')
- colorText(6,3,"Damckell Draconic Monitor; DDM",'gray','white')
- cellType = "8 / Unknown"
- if getMaxEnergy() == 45500000 then
- cellType = "1"
- elseif getMaxEnergy() == 273000000 then
- cellType = "2"
- elseif getMaxEnergy() == 1640000000 then
- cellType = "3"
- elseif getMaxEnergy() == 9880000000 then
- cellType = "4"
- elseif getMaxEnergy() == 59300000000 then
- cellType = "5"
- elseif getMaxEnergy() == 356000000000 then
- cellType = "6"
- elseif getMaxEnergy() == 2140000000000 then
- cellType = "7"
- end
- colorText(width-18,3,"Tier Level "..cellType,'gray','white')
- bgColor('darkgray')
- fgColor('white')
- draw(8,9,100,3)
- colorDraw(8,9,getEnergyPercent(),3,'red')
- os.sleep(0.5)
- prevPercent = getEnergyPercent()
- while loopActive do
- if getEnergyPercent() ~= prevPercent then
- draw(8,9,100,3)
- colorDraw(8,9,getEnergyPercent(),3,'red')
- prevPercent = getEnergyPercent()
- end
- term.setCursor(14,8)
- print("Energy Cell: "..getEnergy().." / "..getMaxEnergy().." ; "..getEnergyPercent().."% - Transfer Rate: "..cell.getTransferPerTick().." RF/t ")
- os.sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement