Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require( "component" )
- local math = require("math")
- local gpu = component.gpu
- local event = require("event")
- local ref = component.ie_refinery
- local squ = component.ie_squeezer
- local fer = component.ie_fermenter
- local gen = component.ie_diesel_generator
- local red = component.redstone
- local lowcap = component.ie_lv_capacitor
- local excav = component.ie_excavator
- local crusher1 = component.proxy("e16d28e5-8ceb-47ad-af31-25f2437de491")
- local crusher2 = component.proxy("e16d28e5-8ceb-47ad-af31-25f2437de491")
- local capacitor1 = component.proxy("96a19d23-86ab-4f97-a21e-1d8f6c1906f0")
- local capacitor2 = component.proxy("429ee133-1889-4fdc-912c-680998dbf300")
- local computer = component.computer
- computer.beep()
- gpu.fill(1,1,130,30," ")
- -- Functions
- local function getClick(_, _, x, y, _, _)
- if (x > 104) and (y > 9) and (x < 112) and (y < 13) then os.execute("/home/power.lua")
- elseif (x > 116) and (y > 9) and (x < 122) and (y < 13) then os.execute("/home/panel.lua") end
- end
- local function mathround(number)
- decimals = 10^(0)
- return math.floor(number * decimals + (0.5))/ decimals
- end
- --Passive Titles
- --these first two is the virtual buttons being drawn on screen which the function getClick will check if the touch is inside them
- gpu.setBackground(0xFF0000)
- gpu.fill(105,10,4,2," ")
- gpu.setBackground(0x008000)
- gpu.fill(117,10,4,2," ")
- gpu.setBackground(0x000000)
- gpu.set(113,8,"Control Panel")
- gpu.setResolution(130,30)
- gpu.set(111,1,"WIP fratty75")
- gpu.set(106,2,"Redstone Signal Strength")
- gpu.set(104,8,"Reboot")
- -- Panel Titles
- gpu.setForeground(0xFF00FF)
- gpu.set(5,12,"Crusher Panel")
- gpu.set(77,24,"Refinery Panel")
- gpu.set(1,24,"Squeezer Panel")
- gpu.set(26,24,"Fermenter Panel")
- gpu.set(109,17,"Capacitor Panel")
- gpu.set(1,1,"Generator Panel")
- gpu.set(52,24,"Excavator Panel")
- gpu.setForeground(0xFFFFFF)
- -- Machine Titles
- gpu.setForeground(0xF8F8FF)
- gpu.set(1,14,"Crusher 1")
- gpu.set(14,14,"Crusher 2")
- gpu.setForeground(0xFF4500)
- gpu.set(103,21,"Medium Voltage")
- gpu.set(103,25,"Medium Voltage")
- gpu.setForeground(0x00FFFF)
- gpu.set(103,29,"Low Volatage")
- --Max Titles
- gpu.setForeground(0xFF0000)
- gpu.set(77,26,"Max Power:")
- gpu.set(1,16,"Max:")
- gpu.set(14,16,"Max:")
- gpu.set(1,26,"Max Power:")
- gpu.set(26,26,"Max Power:")
- gpu.set(52,26,"Max Power:")
- --More passive Titles
- gpu.setForeground(0xF8F8FF)
- gpu.set(1,19,"Current:")
- gpu.set(14,19,"Current:")
- gpu.set(1,29,"Current Power:")
- gpu.set(26,29,"Current Power:")
- gpu.set(77,29,"Current Power:")
- gpu.set(52,29,"Current Power:")
- gpu.set(103,20,"Current Power in Capacitor 1")
- gpu.set(103,24,"Current Power in Capacitor 2")
- gpu.set(103,28,"Current Power in Capacitor 3")
- gpu.setForeground(0x00FF00)
- gpu.set(42,29,"Active:")
- gpu.set(17,29,"Active:")
- gpu.set(68,29,"Active:")
- gpu.set(18,6,"Active")
- gpu.setForeground(0x8B4513)
- gpu.set(1,3,"Internal Tank")
- gpu.set(1,5,"Capacity:")
- gpu.set(1,7,"Current:")
- event.listen("touch", getClick)
- while true do
- --Calls
- local squeezermax = tostring(squ.getMaxEnergyStored())
- local squeezercurrent = tostring(squ.getEnergyStored())
- local fermentermax = tostring(fer.getMaxEnergyStored())
- local fermentercurrent = tostring(fer.getEnergyStored())
- local excavatormax = tostring(excav.getMaxEnergyStored())
- local excavatorcurrent = tostring(excav.getEnergyStored())
- local crushMS = tostring(crusher1.getMaxEnergyStored())
- local crushCS = tostring(crusher1.getEnergyStored())
- local refinerymax = tostring(ref.getMaxEnergyStored())
- local refinerycurrent = tostring(ref.getEnergyStored())
- local crushM2S = tostring(crusher2.getMaxEnergyStored())
- local crushC2S = tostring(crusher2.getEnergyStored())
- local statusgenerator = tostring(gen.isActive())
- local statussqueezer = tostring(squ.isActive())
- local statusfermenter = tostring(fer.isActive())
- local statusexcavator = tostring(excav.isActive())
- local cap1P = capacitor1.getEnergyStored()
- local cap1M = capacitor1.getMaxEnergyStored()
- local cap2M = capacitor2.getMaxEnergyStored()
- local cap1PS = tostring(cap1P)
- local cap2P = capacitor2.getEnergyStored()
- local cap2PS = tostring(cap2P)
- local lowcapP = tostring(lowcap.getEnergyStored())
- local generatortankCapacity = gen.getTankInfo()["capacity"]
- local generatortankCapacityS = tostring(generatortankCapacity)
- local generatortankAmount = gen.getTankInfo()["amount"]
- local generatortankAmountS = tostring(generatortankAmount)
- local red1 = component.proxy("e99223fa-90e2-4287-913d-9bb93e56c837").getInput(5)
- local red2 = tostring(red1)
- --Graph 1
- gpu.setBackground(0x808080)
- local setx = 29
- local sety = 3
- local setextx = 30
- local setexty = 3
- gpu.fill(setx,sety,setextx,setexty," ")
- local graphx = (setx + 1)
- local graphy = (sety + 1)
- local graphextx = (setextx - 2)
- local graphexty = (setexty - 2)
- local yom = ((graphextx*generatortankAmount/generatortankCapacity))
- local generatorpercent = mathround(((generatortankAmount/generatortankCapacity)*100))
- gpu.set(29,7,"Tank is " ..generatorpercent.. "% full")
- gpu.setBackground(0x8B4513)
- gpu.fill(graphx, graphy, yom, graphexty," ")
- gpu.setBackground(0x000000)
- --Graph 2
- gpu.setBackground(0xFFFFFF)
- local setx2 = 29
- local sety2 = 13
- local setextx2 = 30
- local setexty2 = 3
- gpu.set(59,14," ")
- gpu.fill(setx2,sety2,setextx2,setexty2," ")
- local graphx2 = setx2 + 1
- local graphy2 = sety2 + 1
- local graphextx2 = setextx2 - 2
- local graphexty2 = setexty2 - 2
- local yom2 = ((graphextx2*cap1P)/cap1M)
- local capacitor1percent = mathround(((cap1P/cap1M)*100))
- gpu.setBackground(0x00FF00)
- gpu.fill(graphx2, graphy2, yom2, graphexty2, " ")
- gpu.setBackground(0x000000)
- gpu.set(29,17,"Capacitor 1 is " ..capacitor1percent.. "% full")
- --Graph 3
- gpu.setBackground(0xFFFFFF)
- local setx3 = 69
- local sety3 = 13
- local setextx3 = 30
- local setexty3 = 3
- gpu.set(99,14," ")
- gpu.fill(setx3,sety3,setextx3,setexty3," ")
- local graphx3 = setx3 + 1
- local graphy3 = sety3 + 1
- local graphextx3 = setextx3 - 2
- local graphexty3 = setexty3 - 2
- local yom3 = ((graphextx3*cap2P)/cap2M)
- local capacitor2percent = mathround(((cap2P/cap2M)*100))
- gpu.setBackground(0x00FF00)
- gpu.fill(graphx3,graphy3,yom3,graphexty3," ")
- gpu.setBackground(0x000000)
- gpu.set(69,17,"Capacitor 2 is " ..capacitor2percent.. "% full")
- gpu.setBackground(0x000000)
- -- Active Max Titles
- gpu.setForeground(0xFF0000)
- gpu.set(1,17,crushMS)
- gpu.set(14,17,crushM2S)
- gpu.set(1,27,squeezermax)
- gpu.set(26,27,fermentermax)
- gpu.set(52,27,excavatormax)
- gpu.set(77,27,refinerymax)
- gpu.setForeground(0xFFFFFF)
- -- Active Current Power Titles
- gpu.setForeground(0xF8F8FF)
- gpu.set(1,20,crushCS)
- gpu.set(14,20,crushC2S)
- gpu.set(1,30,squeezercurrent)
- gpu.set(26,30,fermentercurrent)
- gpu.set(52,30,excavatorcurrent)
- gpu.set(77,30,refinerycurrent)
- gpu.set(103,22,cap1PS)
- gpu.set(103,26,cap2PS)
- gpu.set(103,30,lowcapP)
- gpu.setForeground(0xFFFFFF)
- -- Active Activity Title
- gpu.setForeground(0x00FF00)
- gpu.set(42,30,statusfermenter)
- gpu.set(17,30,statussqueezer)
- gpu.set(68,30,statusexcavator)
- gpu.set(18,7,statusgenerator)
- gpu.setForeground(0x8B4513)
- gpu.set(10,5,generatortankCapacityS)
- gpu.set(9,7,generatortankAmountS)
- gpu.set(111,3,red2)
- --Monitoring
- if (cap1P < 100000) then
- fer.setEnabled(false)
- squ.setEnabled(false)
- elseif (cap1P < 800000) then
- red.setOutput(5,15)
- elseif (cap1P > 800000) and (cap2P > 800000) then
- red.setOutput(5,0)
- fer.setEnabled(true)
- squ.setEnabled(true)
- end
- os.sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement