feat: add status bar
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user