From b4445da204cc0eca8564b4ba4e6a8924f5bc4fab Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Fri, 28 Nov 2025 22:42:54 +0100 Subject: [PATCH] feat: add star progress bar --- src/lib/aoc.lua | 7 ++++++- src/lib/utils.lua | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/aoc.lua b/src/lib/aoc.lua index da64644..713029e 100644 --- a/src/lib/aoc.lua +++ b/src/lib/aoc.lua @@ -10,6 +10,7 @@ END_DATE = {day=12, month=12, year=2025} local json = require("json") local dates = require("dates") local days = require("days") +local progress = require "progress" local today = os.date("*t") local function loadStats(path) @@ -90,9 +91,13 @@ local function printStats(stats, selected) term.setTextColor(colors.white) write(string.format("You have %d", stars)) term.setTextColor(colors.orange) - write("\x04") + write("\x04 ") + local x, y = term.getCursorPos() + progress.bar(x, y, 20, stars, 24, colors.orange, colors.gray) term.setTextColor(colors.white) print() + print() + print("Press END to quit") end local function printBanner() diff --git a/src/lib/utils.lua b/src/lib/utils.lua index 4a78789..3ae6ea4 100644 --- a/src/lib/utils.lua +++ b/src/lib/utils.lua @@ -86,4 +86,8 @@ function utils.splitLines(data) return t end +function utils.round(x) + return x >= 0 and math.floor(x + 0.5) or math.ceil(x - 0.5) +end + return utils