\255\numR\numG\numB
Caveats:
The numbers RGB cannot end with 0. Not sure exactly why but I assume its just a bug in the engine.
There is no support for Alpha; the \255 at the start is not an Alpha (at least it doesn't work as such) it is merely a character handle for colourizing.
So:
Code: Select all
Spring.Echo("\255\255\1\1This text is red")
Spring.Echo("\255\1\255\1This text is green")
Spring.Echo("\255\1\1\255This text is blue")
Spring.Echo("\255\1\255\127This text is Spring Green!")
Below is a function that gets a player's colour from the game and converts it into the above handle for text.
Code: Select all
function colorNames(teamID)
nameColorR,nameColorG,nameColorB,nameColorA = spGetTeamColor(teamID)
R255 = math.floor(nameColorR*255)
G255 = math.floor(nameColorG*255)
B255 = math.floor(nameColorB*255)
if ( R255%10 == 0) then
R255 = R255+1
end
if( G255%10 == 0) then
G255 = G255+1
end
if ( B255%10 == 0) then
B255 = B255+1
end
return "\255"..string.char(R255)..string.char(G255)..string.char(B255) --works thanks to zwzsg
end
Code: Select all
playerColor = colorNames(Spring.GetMyTeamID)
message = playerColor.."This text is the same colour as me!"
Spring.SendCommands("say "..string.format(message))