Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Load and configure dependencies, don't touch!
- os.loadAPI( "ProgressBar" )
- -- Configurable settings go here
- monitorLocation = "front"
- rednetLocation = "right"
- monitorFontSize = 1.5
- -- Configurable settings end
- -- Prepare dependencies
- monitor = peripheral.wrap( monitorLocation )
- monitor.clear()
- monitor.setTextScale( monitorFontSize )
- local monitorSize = monitor.getSize()
- barWidth = ( monitorSize / monitorFontSize ) + 15
- textPosition = barWidth + 15
- ProgressBar.SetPeripheral( monitorLocation )
- monitor.setCursorPos( 5, 4 )
- monitor.write( "Energy storage (0/0)" )
- ProgressBar.SetTable( "Power", 100, 0, 5, barWidth, 5 )
- ProgressBar.DrawToPeripheral()
- monitor.setCursorPos( 5, 7 )
- monitor.write( "AE Storage (0/0)" )
- ProgressBar.SetTable( "AEBytes", 100, 0, 5, barWidth, 8 )
- ProgressBar.DrawToPeripheral()
- --
- function stringSplit( str )
- local t = {}
- local function helper( word )
- table.insert( t, word )
- return ""
- end
- if not str:gsub( "%w+", helper ):find"%S" then
- return t
- end
- end
- function parseMsg( id, msg )
- local incomingLine = stringSplit( msg )
- if "power" == incomingLine[1] then
- local used = incomingLine[2]
- local available = incomingLine[3]
- local remainder = ( used / available ) * 100
- ProgressBar.SetCurValue( "Power", remainder )
- monitor.setCursorPos( 5, 4 )
- monitor.write( "Energy storage (" .. used .. " / " .. available .. ")" )
- end
- if "ae" == incomingLine[1] then
- local used = incomingLine[2]
- local available = incomingLine[3]
- local remainder = ( used / available ) * 100
- ProgressBar.SetCurValue( "AEBytes", remainder )
- monitor.setCursorPos( 5, 4 )
- monitor.write( "AE Storage (" .. used .. " / " .. available .. ")" )
- end
- ProgressBar.DrawToPeripheral()
- end
- rednet.open( rednetLocation )
- while true do
- id, msg, time = rednet.receive()
- print( msg )
- print( id )
- parseMsg( id, msg )
- end
- rednet.close( rednetLocation )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement