--[[
rebind: min_sdk=3.0.0
rebind: name=Build Status Watcher
--]]
local cfg = UI.Schema({
enabled = UI.Toggle(true, { label = "Enable" }),
x = UI.Slider(40, { min = 0, max = 4000, label = "Sample X" }),
y = UI.Slider(40, { min = 0, max = 4000, label = "Sample Y" }),
target = UI.Text("E53935", { maxLength = 6, label = "Alert Color (hex)" }),
tolerance = UI.Slider(24, { min = 0, max = 100, label = "Tolerance" }),
})
local fired = false
local function hexToRgb(hex)
return tonumber(hex:sub(1, 2), 16),
tonumber(hex:sub(3, 4), 16),
tonumber(hex:sub(5, 6), 16)
end
local function distance(a, b)
local r1, g1, b1 = hexToRgb(a)
local r2, g2, b2 = hexToRgb(b)
return math.sqrt((r2 - r1) ^ 2 + (g2 - g1) ^ 2 + (b2 - b1) ^ 2)
end
function OnTick()
if not cfg.enabled then
return
end
local pixel = Screen.GetPixelColor(cfg.x, cfg.y)
local matched = distance(pixel, cfg.target) <= cfg.tolerance
-- edge-triggered: act once when the state appears, reset when it clears
if matched and not fired then
fired = true
UI.Notify("Build status: alert color is showing", "warning")
Run(function()
HID.Press("F5")
end) -- refresh the dashboard
elseif not matched then
fired = false
end
end