Color question!

Anonynn
13 Feb 2016, 02:35
I was wondering...is there a way to change the color of text depending on a character talking?

Like, for example....

<color: black>"Hello, I'm the main character."</color:black>

<color:purple>"Hello, I'm your friend, main character."</color:purple>

I know that is NOT the correct syntax for text color but I wanted to make a quick example! These would have to work in scripts, and switch/if scripts as well.

XanMag
13 Feb 2016, 02:42
I'll give you the exact code when I get home if not given already, but if you want to download my .aslx tutorial and look at the "fancy output" room, it's in there!! :)

.aslx is in game announcements forum.

<font color = "red">blah blah blah</font>

<font color = "purple">blah blah blah</font>

Try that. Something like that.

Anonynn
13 Feb 2016, 03:20
Thank you very much, Xan!


Hmmm....doesn't seem to work in the "switch code" at all. I haven't tried it elsewhere. One sec.

It does work in "text" so far, but I'm not sure I'm going to use it. A lot of the text I have takes place in "Switch Scripts" and "If Scripts". Thanks anyways though!

XanMag
13 Feb 2016, 04:21
What message does it kick back in the switch script? Or does it just print black?

Cylius_Optimi
13 Feb 2016, 04:50
If you want to put color into your messages/strings:
<font color="ValidHTMLColor">Your Text</font>

If you want to change text color for the entire game:
SetForegroundColour ("ValidHTMLColor")


If you want to change background color for the entire game:
SetBackgroundColour ("ValidHTMLColor")


Valid HTML colors. You can also use Hexadecimal color (#RRGGBB).

Anonynn
13 Feb 2016, 05:24

What message does it kick back in the switch script? Or does it just print black?



It pretty much destroys all the coding in that particular section xD meaning none of it works at all. Every error code goes off in any particular part I use... <font color = "blue">Blah Blah</font> this in. It DOES work for plain text boxes, and probably normal scripts as well. But for "Switch/If's" it's a big no. Unless it might be because I have a Function inside of them.

If you want to put color into your messages/strings:


Code: Select all
<font color="ValidHTMLColor">Your Text</font>

If you want to change text color for the entire game:

Code: Select all
SetForegroundColour ("ValidHTMLColor")


If you want to change background color for the entire game:

Code: Select all
SetBackgroundColour ("ValidHTMLColor")


Valid HTML colors. You can also use Hexadecimal color (#RRGGBB).



Hmm...again, these won't work in "Switch/If"'s ...I'm assuming since there is a \ "" + Function("") + "\" in them.

Cylius_Optimi
13 Feb 2016, 05:35
Neonayon wrote:

What message does it kick back in the switch script? Or does it just print black?



It pretty much destroys all the coding in that particular section xD meaning none of it works at all. Every error code goes off in any particular part I use... <font color = "blue">Blah Blah</font> this in. It DOES work for plain text boxes, and probably normal scripts as well. But for "Switch/If's" it's a big no. Unless it might be because I have a Function inside of them.

If you want to put color into your messages/strings:
[quote]
Code: Select all
<font color="ValidHTMLColor">Your Text</font>

If you want to change text color for the entire game:

Code: Select all
SetForegroundColour ("ValidHTMLColor")


If you want to change background color for the entire game:

Code: Select all
SetBackgroundColour ("ValidHTMLColor")


Valid HTML colors. You can also use Hexadecimal color (#RRGGBB).



Hmm...again, these won't work in "Switch/If"'s ...I'm assuming since there is a \ "" + Function("") + "\" in them.[/quote]


If you're using the code editor, here's an updated set.

What will work in String/Messages:
string = "<font color=\"ValidHTMLColor\">Text Here</font>"

What will NOT work:
string = "<font color="ValidHTMLColor">Text Here</font>"


Why is this?
Quest will read the pair of quotation marks as a sudden end of the string, plus some other 'stuff'. You have to cancel(?) them with backslash to make Quest (and JavaScript, and Java, etc) ignore them.

The graphical editor with insert the proper canceling into your code, things you never see. Quest games are, at their root, stored in XML, and because of this, you also need to mind your use of angle brackets (<>). By default, Quest will also insert the tags <![CDATA[ and ]]> at the start and end of your script in order to...

It's late, and I've forgotten the proper phrase. Basically, those tags tell XML that any brackets or XML code between them should be ignored.

If you want to assemble a string/message from a character-specific color:
string = "<font color=\"" +CharacterColorString+ "\">Text Here</font>[/code


If this doesn't solve your question, you should post the block of code giving you trouble.

Anonynn
13 Feb 2016, 06:17
I think I get how/why it works, (although I appreciate the explanation!) But what I mean is...I have manipulate text inside of a text processor function command...like this.

\ "" + FunctionName("Blah blah!") + "\"

So would that font coding you suggested look like this?

string = "<font color=\"ValidHTMLColor\"> "\" + FunctionName("Text Here") + "\" </font> ?

or

\"" + FunctionName("string = "<font color=\"ValidHTMLColor\">Text Here</font>"") + "\"

although I believe the latter would have all kinds of errors x)

Cylius_Optimi
13 Feb 2016, 06:20
Provided you make sure to actually insert a valid HTML color (such as red, blue, green) then the first one will work, yes. If you wish to print that output to a message, you wouldn't use "string =", though.

jaynabonne
13 Feb 2016, 08:47
If you want to have things like "<" and ">" in strings while in code view you need to enclose the script body in a CDATA block. Otherwise, the XML parser tries to interpret what's inside your strings as part of the outer XML markup.

A simple example:

<function name="somefunc">
<![CDATA[
msg ("<font color=\"red\">Hello world</font>")
]]>
</function>


If you don't have the <!CDATA[ ... ]]> enclosing your script, you will get errors!

You should be able to use markup in your strings wherever you want (any sort of switch/if/whatever script) if you've escaped it properly.

A minor note: the "font" tag is considered deprecated and won't be supported in HTML5. You might be better off in the long run using a class for each character and then setting the class attributes in CSS rather than spreading the color info all through your strings:

<span class="Jimmy">What the heck is going on here?</span>

<span class="Mary">I don't know, but I think we should get a move on!</span>


That way, if you decide to change the color (or any other part of the styling), you can change it in one place rather than every string in the game.

Cylius_Optimi
13 Feb 2016, 17:50
jaynabonne wrote:If you want to have things like "<" and ">" in strings while in code view you need to enclose the script body in a CDATA block. Otherwise, the XML parser tries to interpret what's inside your strings as part of the outer XML markup.

A simple example:

<function name="somefunc">
<![CDATA[
msg ("<font color=\"red\">Hello world</font>")
]]>
</function>


If you don't have the <!CDATA[ ... ]]> enclosing your script, you will get errors!

You should be able to use markup in your strings wherever you want (any sort of switch/if/whatever script) if you've escaped it properly.


Ah, yes. Escaping; that's the phrase that was escaping me last night.

jaynabonne wrote:A minor note: the "font" tag is considered deprecated and won't be supported in HTML5. You might be better off in the long run using a class for each character and then setting the class attributes in CSS rather than spreading the color info all through your strings:

<span class="Jimmy">What the heck is going on here?</span>

<span class="Mary">I don't know, but I think we should get a move on!</span>


That way, if you decide to change the color (or any other part of the styling), you can change it in one place rather than every string in the game.


Even though I'm not OP, this little tidbit is very good to know for the future.