Your id, r, g, b = v.match(v, "%$color(%d+)%:%s+rgba%((%d+)%,%s+(%d+)%,%s+(%d+)%,%s+%d+%)%;") or 0, 0, 0, 0
line is parsed by Lua as
id = v:match(pattern) or 0
r = 0
g = 0
b = 0
Since there is a match, the id
variable is set to the capturing group 1 value, the rest is assigned with zeros.
You may fix this assignment using tables:
result = {string.match(v, "%$color(%d+):%s+rgba%((%d+),%s+(%d+),%s+(%d+),%s+%d+%);")}
id, r, g, b = result[1] or 0, result[2] or 0, result[3] or 0, result[4] or 0
See the Lua demo.
NOTE:;
and ,
are not special Lua pattern characters, hence I removed %
escapes in front of them in the pattern.