From 84637cb3dd329155acaea93d56d2b4bc45090548 Mon Sep 17 00:00:00 2001 From: neru Date: Wed, 7 May 2025 23:45:45 -0300 Subject: [PATCH] feat: add status bar --- lua/CC Tweaked/tutel/tutel-host.lua | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lua/CC Tweaked/tutel/tutel-host.lua b/lua/CC Tweaked/tutel/tutel-host.lua index 8e8415f..068372b 100644 --- a/lua/CC Tweaked/tutel/tutel-host.lua +++ b/lua/CC Tweaked/tutel/tutel-host.lua @@ -201,7 +201,7 @@ registerEventListener("key", scrollLogs) --[[ drawing functions ]] -local function drawLogs(x0, y0, x1, y1) +function drawLogs(x0, y0, x1, y1) local w = x1 - x0 local h = y1 - y0 @@ -217,17 +217,17 @@ local function drawLogs(x0, y0, x1, y1) local prevColourBg = term.getBackgroundColour() local prevColourFg = term.getTextColour() - term.setBackgroundColour(format["BG"]) - term.setTextColour(format["FG"]) + term.setBackgroundColor(format["BG"]) + term.setTextColor(format["FG"]) term.write(("[%s]"):format(entry.type)) if format["AffectContent"] then term.write((" %s\n"):format(entry.message)) - term.setBackgroundColour(prevColourBg) - term.setTextColour(prevColourFg) + term.setBackgroundColor(prevColourBg) + term.setTextColor(prevColourFg) else - term.setBackgroundColour(prevColourBg) - term.setTextColour(prevColourFg) + term.setBackgroundColor(prevColourBg) + term.setTextColor(prevColourFg) term.write((" %s\n"):format(entry.message)) end @@ -235,6 +235,17 @@ local function drawLogs(x0, y0, x1, y1) end end +function drawStatusBar(y) + term.setCursorPos(1, y) + + term.setBackgroundColor(colors.green) + term.setTextColor(colors.white) + term.clearLine() + + local str = ("turtles: %d"):format(#turtles) + term.write(str) +end + --[[ main loop functions ]] @@ -264,8 +275,8 @@ function updateScreen() term.setBackgroundColor(colors.black) term.setTextColour(colors.white) - -- logs drawLogs(1, 2, w, h - 1) + drawStatusBar(h) end function pollEvents()