Jump to content
iSassafras

Format text with color using variables

Recommended Posts

Hey guys and Merry Christmas!

 

I'm using a continuous set of colors for the titles of addAction commands or hints throughout my mission. Since it's always the same four colors I use, I would like to use public variables containing a string with their hex codes, but I can't make it work. Do you have any suggestions?

For example, right now I use a format command like this:

format ["Request <t color='#ED0C3B'>%1</t>", _text]


I tried using it like this:

OS_red = "#ED0C3B";
publicVariable "OS_red";

format ["Request <t color=%1>%2</t>", OS_red, _text];

But the text isn't colored this way. I guess because the quotes get removed before format inserts the content of my variable into the text?

 

Share this post


Link to post
Share on other sites
3 hours ago, M1ke_SK said:

format ["Request <t color='%1'>%2</t>", OS_red, _text];

 

I tried that already, it didn't work. But thanks anway!

 

57 minutes ago, pierremgi said:

Don't forget:

hint parseText format ["Request <t color='%1'>%2</t>", OS_red, _text] (for hint).

 

Right! Thank you! Why didn't I come up with this? Lol.
Gotta try if works for addAction titles too.

 

Share this post


Link to post
Share on other sites
26 minutes ago, iSassafras said:

Gotta try if works for addAction titles too.

Not mandatory in addAction

  • Thanks 1

Share this post


Link to post
Share on other sites
On 12/24/2020 at 10:56 PM, pierremgi said:

Not mandatory in addAction

Yeah, I just tried it. If I use parseText any addAction will return an error saying it expected string not text. Any other suggestions?

Share this post


Link to post
Share on other sites
48 minutes ago, iSassafras said:

Yeah, I just tried it. If I use parseText any addAction will return an error saying it expected string not text. Any other suggestions?

I said it's "not mandatory"... Read "not true".

_someObject addAction [  "<t color='#ff5555' size='1.2'>yourTextMenu</t>",  { someCode}]

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, pierremgi said:

I said it's "not mandatory"... Read "not true".

_someObject addAction [  "<t color='#ff5555' size='1.2'>yourTextMenu</t>",  { someCode}]

 

I see! Sorry, I misread your message.

Thanks for the help!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×