Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Stranga on Sat 31/07/2021 04:00:29

Title: A way to change the color of one word out of a string? [SOLVED]
Post by: Stranga on Sat 31/07/2021 04:00:29
Hello everyone,

I was wondering if there is a way to change the color of 1 or 2 words out of a string rather than just the whole string? I had a look at possibly using the Text Phraser but was wondering if there were a way to do it in code first. Any help would be greatly appreciated :) Also going through the manual now to see if I've missed anything related to this.

For example: (The underlined word is in a different color from the main string)
[imgzoom]https://www.newgrounds.com/dump/draw/d9042468b11d57636f74c504539b967f[/imgzoom]
Title: Re: A way to change the color of one word out of a string?
Post by: Cassiebsg on Sat 31/07/2021 15:37:45
There might be a module (or plugin) for that.

But check Overlay.CreateTextual in the manual, think that's what you want. :)
Title: Re: A way to change the color of one word out of a string?
Post by: Stranga on Sun 01/08/2021 05:07:06
Thanks or your help Cassie! Checking out Over.ay.CreateTexual now. Also, forgot to mention I'm using a custom dialogue script (Not sure if that makes a difference or not).
Title: Re: A way to change the color of one word out of a string?
Post by: Khris on Sun 01/08/2021 13:46:51
It depends on the context. If we're talking about drawing strings, you can probably use DrawStringWrapped to draw the white text in full, then use GetTextWidth and GetTextHeight for "There was a " to get the coordinates of where to draw the colored "key" string.

But inside a label text or Display command, AGS doesn't support multiple colors.
Title: Re: A way to change the color of one word out of a string?
Post by: Stranga on Sun 01/08/2021 22:28:45
Ah I see, thanks Khris. I thought it may have supported multiple colors but the DrawStringWrapped seems like an interesting approach.