Coloured text problem

retroPacifist
11 Nov 2016, 01:44

In my game, I have the line of code:

"<font color="HEX CODE"">skatingHeliophile [SH]</font color> began pestering " + (player.chumhandlefirst) + (player.chumhandlelast) + " [" + (player.chumhuandleinitials) + "]"

My variables are all set, but when I paste the code into a message, it doesn't set the attributes and attributes, just bracketed text. But when I put the code into an expression, it give me an error because of the < or > or something.


R2T1
11 Nov 2016, 05:31

I haven't tested this but just reading your line of code, it looks like you have the quotes after HEX CODE in the wrong place.
Shouldn't it be ... font color="HEX CODE">"skatingHeliophile ...


retroPacifist
11 Nov 2016, 07:03

I'm sorry I'm not sure I understand, this, can you please explain this a little more clearly?


The Pixie
11 Nov 2016, 08:10

Just replied on another thread, but I see what you are trying to do here. There is a problem with the HTML tags, which may be the issue here. Firstly, you need to swap HEX CODE for the actual hex code for the colour, with a # at the start (or the name of a colour). Secondly you need to "escape" the quotes to tell Quest the quotes should be part of the string, rather than saying it is the start or end, and to do that put a backslash before them. Thirdly you have two of them at one point. Fourthly the end tag should not have "color" in it.

This will make it yellow, hopefully:

"<font color=\"#808000\">skatingHeliophile [SH]</font> began pestering " + (player.chumhandlefirst) + (player.chumhandlelast) + " [" + (player.chumhuandleinitials) + "]"

So will this:

"<font color=\"yellow\">skatingHeliophile [SH]</font> began pestering " + (player.chumhandlefirst) + (player.chumhandlelast) + " [" + (player.chumhuandleinitials) + "]"

retroPacifist
11 Nov 2016, 09:45

Okay, so my code is currently:

"<font color=\”#(My hex code is here)\”>skatingHeliophile [SH] began pestering " + (Player.chumhandlefirst) + (Player.chumhandlelast) + " [" + (Player.chumhuandleinitials) + "]"

But there's still a problem. When the code is in an expression, the game says this:

Error running script: Error compiling expression '"<font color=\”#(My hex code is here)\”>"skatingHeliophile [SH] began pestering " + (Player.chumhandlefirst) + (Player.chumhandlelast) + " [" + (Player.chumhuandleinitials) + "]"
"': SyntaxError: Unexpected character: "Line: 1, Column: 1

But when it's a message the error reads the same thing.


The Pixie
11 Nov 2016, 12:02

Can you go into code view and copy-and-paste exactly what you have there? It should be like this:

msg("<font color=\"#808000\">skatingHeliophile [SH]</font> began pestering " + (player.chumhandlefirst) + (player.chumhandlelast) + " [" + (player.chumhuandleinitials) + "]")

I am wondering if the msg is missing.


retroPacifist
11 Nov 2016, 12:10
msg ("\"<font color=\\"#808000\\">skatingHeliophile [SH]</font> began pestering \" + (player.chumhandlefirst) + (player.chumhandlelast) + \" [\" + (player.chumhuandleinitials) + \"]\"")

This is the code view for the line of code.


The Pixie
11 Nov 2016, 14:07

At some point it has got confused between printing a message and an expression. The code you were discussing above is an expression, but has been put in as a message, and then converted into an expression after that, which is why it has all those extra backslashes. Try just replacing the entire line (msg and all) with the code in my previous post.


retroPacifist
11 Nov 2016, 14:16

I figured out the solution to the problem. The code I ended up using was:

OutputTextNoBr ("<font color=\\\"#808000\\\">skatingHeliophile [SH]</font> began pestering ")
OutputTextNoBr ((Player.chumhandlefirst) + (Player.chumhandlelast) + " [" + (Player.chumhuandleinitials) + "]")