Meh, I don't have the time to do it right now.
Here's the RGB->Grayscale formula though:
Y=0.212671*R+0.715160*G+0.072169*B
I know the default color set uses decimals in a few parts, like:
1.000 0.000 1.000 1.000 for 100% opacity pink.
Multiply those decimals by 255, THEN use the formula above.