Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MonitorSide = "monitor_84"
- -- MESystemPCSide = "appeng_me_tilecontroller_4"
- MESystemPCSide = "left"
- Monitor = peripheral.wrap(MonitorSide)
- MESystemPC = peripheral.wrap(MESystemPCSide)
- InfoFetchDelay = 5
- function ClearMonitor()
- Monitor.setTextColor(colours.black)
- Monitor.setBackgroundColor(colours.black)
- Monitor.clear()
- Monitor.setCursorPos(1,1)
- end
- function DrawText(xPos, yPos, text, textColour, backgroundColour)
- Monitor.setBackgroundColor(backgroundColour)
- Monitor.setTextColor(textColour)
- Monitor.setCursorPos(xPos,yPos)
- Monitor.write(text)
- end
- function DrawLine(x, y, lineLength, colour)
- Monitor.setBackgroundColor(colour)
- Monitor.setTextColor(colour)
- Monitor.setCursorPos(x,y)
- Monitor.write(string.rep(" ", lineLength))
- end
- function ProgressBar(xPos, yPos, barLength, value, maxValue, backgroundColour, progressColour)
- DrawLine(xPos, yPos, barLength, backgroundColour) --backgoround bar
- local barSize = math.floor((value/maxValue) * barLength)
- DrawLine(xPos, yPos, barSize, progressColour) --progress so far
- end
- function MainFunc()
- if (MESystemPC == nil) then
- MESystemPC = peripheral.wrap(MESystemPCSide)
- return
- end
- if (Monitor == nil) then
- Monitor = peripheral.wrap(MonitorSide)
- return
- end
- local totalBytes = MESystemPC.getTotalBytes()
- local freeBytes = MESystemPC.getFreeBytes()
- local monX, monY = Monitor.getSize()
- ClearMonitor()
- DrawText(2, 2, "ME System Storage Monitor", colours.white, colours.black)
- DrawText(2, 3, string.rep("-", monX - 2), colours.white, colours.black)
- DrawText(2, 4, "Total Bytes", colours.white, colours.black)
- DrawText(2, 5, math.floor(totalBytes / 1000000) .. " MB", colours.white, colours.black)
- DrawText(2, 6, string.rep("-", monX - 2), colours.white, colours.black)
- DrawText(2, 7, "Used Bytes", colours.white, colours.black)
- local usedBytes = totalBytes - freeBytes
- ProgressBar(2, 8, monX - 2, usedBytes, totalBytes, colours.grey, colours.lightBlue)
- DrawText(2, 9, string.rep("-", monX - 2), colours.white, colours.black)
- DrawText(2, 10, "Free Bytes", colours.white, colours.black)
- ProgressBar(2, 11, monX - 2, freeBytes, totalBytes, colours.grey, colours.lightBlue)
- end
- while true do
- MainFunc()
- sleep(InfoFetchDelay)
- end
Add Comment
Please, Sign In to add comment