feat: add status bar
This commit is contained in:
@@ -201,7 +201,7 @@ registerEventListener("key", scrollLogs)
|
|||||||
--[[
|
--[[
|
||||||
drawing functions
|
drawing functions
|
||||||
]]
|
]]
|
||||||
local function drawLogs(x0, y0, x1, y1)
|
function drawLogs(x0, y0, x1, y1)
|
||||||
local w = x1 - x0
|
local w = x1 - x0
|
||||||
local h = y1 - y0
|
local h = y1 - y0
|
||||||
|
|
||||||
@@ -217,17 +217,17 @@ local function drawLogs(x0, y0, x1, y1)
|
|||||||
local prevColourBg = term.getBackgroundColour()
|
local prevColourBg = term.getBackgroundColour()
|
||||||
local prevColourFg = term.getTextColour()
|
local prevColourFg = term.getTextColour()
|
||||||
|
|
||||||
term.setBackgroundColour(format["BG"])
|
term.setBackgroundColor(format["BG"])
|
||||||
term.setTextColour(format["FG"])
|
term.setTextColor(format["FG"])
|
||||||
term.write(("[%s]"):format(entry.type))
|
term.write(("[%s]"):format(entry.type))
|
||||||
|
|
||||||
if format["AffectContent"] then
|
if format["AffectContent"] then
|
||||||
term.write((" %s\n"):format(entry.message))
|
term.write((" %s\n"):format(entry.message))
|
||||||
term.setBackgroundColour(prevColourBg)
|
term.setBackgroundColor(prevColourBg)
|
||||||
term.setTextColour(prevColourFg)
|
term.setTextColor(prevColourFg)
|
||||||
else
|
else
|
||||||
term.setBackgroundColour(prevColourBg)
|
term.setBackgroundColor(prevColourBg)
|
||||||
term.setTextColour(prevColourFg)
|
term.setTextColor(prevColourFg)
|
||||||
term.write((" %s\n"):format(entry.message))
|
term.write((" %s\n"):format(entry.message))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -235,6 +235,17 @@ local function drawLogs(x0, y0, x1, y1)
|
|||||||
end
|
end
|
||||||
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
|
main loop functions
|
||||||
]]
|
]]
|
||||||
@@ -264,8 +275,8 @@ function updateScreen()
|
|||||||
term.setBackgroundColor(colors.black)
|
term.setBackgroundColor(colors.black)
|
||||||
term.setTextColour(colors.white)
|
term.setTextColour(colors.white)
|
||||||
|
|
||||||
-- logs
|
|
||||||
drawLogs(1, 2, w, h - 1)
|
drawLogs(1, 2, w, h - 1)
|
||||||
|
drawStatusBar(h)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pollEvents()
|
function pollEvents()
|
||||||
|
|||||||
Reference in New Issue
Block a user