diff --git a/src/lib/progress.lua b/src/lib/progress.lua new file mode 100644 index 0000000..6bde1cc --- /dev/null +++ b/src/lib/progress.lua @@ -0,0 +1,12 @@ +local utils = require("utils") +local progress = {} + +function progress.bar(x, y, width, value, max, fg, bg) + local fgWidth = utils.round(value * width / max) + fgWidth = math.max(0, math.min(width, fgWidth)) + paintutils.drawLine(x, y, x + width - 1, y, bg) + paintutils.drawLine(x, y, x + fgWidth - 1, y, fg) + term.setBackgroundColor(colors.black) +end + +return progress \ No newline at end of file