It's a little sloppy. There are other ways of going about it (moveCursor and selectLine functions are worth a look), but you could create a trigger group, put your first line in as a pattern and set the fire length to however many the max amount of…
function isRGB(cg,red,green,blue) selectCaptureGroup(tonumber(cg)) local r,g,b = getFgColor() if red == r and green == g and blue == b then return true