feat: Update dashboard header to display the count of online turtles
This commit is contained in:
@@ -89,12 +89,18 @@ local function drawDashboard()
|
|||||||
monitor.setBackgroundColor(colors.black)
|
monitor.setBackgroundColor(colors.black)
|
||||||
monitor.clear()
|
monitor.clear()
|
||||||
|
|
||||||
|
-- Count turtles
|
||||||
|
local turtleCount = 0
|
||||||
|
for _ in pairs(turtles) do
|
||||||
|
turtleCount = turtleCount + 1
|
||||||
|
end
|
||||||
|
|
||||||
-- Simple header
|
-- Simple header
|
||||||
monitor.setBackgroundColor(colors.blue)
|
monitor.setBackgroundColor(colors.blue)
|
||||||
monitor.setTextColor(colors.white)
|
monitor.setTextColor(colors.white)
|
||||||
monitor.setCursorPos(1, 1)
|
monitor.setCursorPos(1, 1)
|
||||||
monitor.clearLine()
|
monitor.clearLine()
|
||||||
centerText(1, "TURTLE BRIDGE - " .. #turtles .. " TURTLES ONLINE", colors.white, colors.blue)
|
centerText(1, "TURTLE BRIDGE - " .. turtleCount .. " ONLINE", colors.white, colors.blue)
|
||||||
|
|
||||||
-- Status line
|
-- Status line
|
||||||
monitor.setBackgroundColor(colors.gray)
|
monitor.setBackgroundColor(colors.gray)
|
||||||
@@ -108,7 +114,7 @@ local function drawDashboard()
|
|||||||
monitor.setBackgroundColor(colors.black)
|
monitor.setBackgroundColor(colors.black)
|
||||||
local startY = 4
|
local startY = 4
|
||||||
|
|
||||||
if #turtles == 0 then
|
if turtleCount == 0 then
|
||||||
monitor.setTextColor(colors.gray)
|
monitor.setTextColor(colors.gray)
|
||||||
monitor.setCursorPos(2, startY)
|
monitor.setCursorPos(2, startY)
|
||||||
monitor.write("No turtles connected. Waiting for signals...")
|
monitor.write("No turtles connected. Waiting for signals...")
|
||||||
|
|||||||
Reference in New Issue
Block a user