Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require( "component" )
- local gpu = component.gpu
- local power = component.mekanism_machine
- local event = require( "event" )
- local oldW, oldH = gpu.getResolution()
- gpu.setResolution( 80, 11 )
- function clearScreen()
- local oldColor = gpu.getBackground( false )
- local w,h = gpu.getResolution()
- gpu.setBackground( 0x000000, false )
- gpu.fill( 1, 1, w, h, " " )
- gpu.setBackground( oldColor, false )
- end
- function progressBar( label, y, value, maxVal, color, show, unit )
- local oldColor = gpu.getBackground( false )
- gpu.setBackground(0x000000, false)
- gpu.fill( 3, y, 75, 2, " " )
- w = math.floor( value * (75 / maxVal) )
- p = math.floor( (w / 75) * 100 )
- gpu.set( 3, y, label .. ": " .. tostring( p ) .. "%" )
- gpu.setBackground( 0x222222, false )
- gpu.fill( 3, y+1, 75, 1, " " )
- gpu.setBackground( color, false )
- gpu.fill( 3, y+1, w, 1, " " )
- gpu.setBackground( oldColor, false )
- if show then
- local valStr = formatBig( value ) .. unit
- local n = string.len( valStr )
- gpu.set( 78 - n, y, valStr )
- end
- end
- function assignTanks()
- local tanks = component.list( "comparator" )
- local t1 = component.getPrimary( "comparator" )
- local t2
- for k,v in tanks do
- local temp = component.proxy( k )
- if t1.address ~= temp.address then t2 = temp end
- end
- return t1,t2
- end
- function formatBig( value )
- local output = ""
- local valRem = 0
- local valPart = 0
- while value > 0 do
- valRem = math.floor( value / 1000 )
- valPart = value - (valRem * 1000)
- if output == "" then
- output = string.format( "%03d", valPart )
- elseif valRem == 0 then
- output = valPart .. "," .. output
- else
- output = string.format( "%03d", valPart ) .. "," .. output
- end
- value = valRem
- end
- return output
- end
- local tank1, tank2 = assignTanks()
- clearScreen()
- local max = math.floor( power.getMaxEnergyStored() * 0.4 )
- local cur = math.floor( power.getEnergyStored() * 0.4 )
- gpu.set( 28, 1, "Reactor Fuel Reserves" )
- gpu.set( 3, 10, "Power Output: 18,000,000 RF/sec" )
- local totalStr = formatBig( max ) .. " RF"
- gpu.set( 78 - string.len( totalStr ), 10, totalStr )
- while true do
- local _,_,x,y = event.pull( 1, "touch" )
- if x and y then goto quit end
- progressBar( "Deuterium", 2, tank2.getOutputSignal(), 15, 0xff0000, false, "" )
- progressBar( "Tritium", 5, tank1.getOutputSignal(), 15, 0x0088ff, false, "" )
- cur = math.floor( power.getEnergyStored() * 0.4 )
- progressBar( "Power Stored", 8, cur, max, 0x00bb00, true, " RF" )
- os.sleep(0.25)
- end
- ::quit::
- gpu.setResolution( oldW, oldH )
- clearScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement