Appending a line with some of the text coloured.

General discussion about the Genesis Web Client located at https://www.genesismud.org/play/

Moderator: Eowul

Forum rules
- Use common sense and be respectful towards each other at all times, even when disagreeing.
- Do not reveal sensitive game information. Guild secrets, player seconds are examples of things not allowed.
Post Reply
Callimachus
Beginner
Posts: 15
Joined: 06 May 2019 03:42

Appending a line with some of the text coloured.

Post by Callimachus » 14 Aug 2019 05:36

I'm tryin to append a line to my screen output, with specific colour for a portion of it. Unfortunately, my simple brain can't seem to get it to work.

A silly example to show the sort of thing I'm trying to do:
If I inventory my backpack, I might get a few lines like:

32 copper coins
83 silver coins

So, say I want to add a line to the output after the silver coins lines such as:

32 copper coins
83 silver coins
need gold coins -- get some

Adding the extra line is easy enough. The problem I'm having is I would like to colour one or more words in that extra line, but not the entire line. So, output 'gold coins' in yellow, leaving the rest in the default colour. I don't want to use gwc.output.replace because I'm not replacing anything. I'm using gwc.output.append, but I can't seem to get colour inserted in there without the actual code I'm trying printing out as well.

I realize this is probably a simple thing, but I hope someone can help me out anyway.

User avatar
Kjartan
Beginner
Posts: 22
Joined: 23 Jan 2021 07:27
Contact:

Re: Appending a line with some of the text coloured.

Post by Kjartan » 03 Feb 2021 16:15

Hey,

you actually want to replace something.
To have words coloured, you surround them with a span tag.
Like:

Code: Select all

<span style="color: YOUR COLOUR">HERE GOES WHATEVER IS TO BE COLOURED</span>
Yes, you could go, and just insert something before and after to achieve this, but the easiest way to achieve the same is, to replace them with

Code: Select all

<span style="color: YOUR COLOUR">THE WORD(S) YOU REPLACE IN ORDER TO BE COLOURED</span>
So, replacing is the easiest way to go, even though you just replace them with themselves and a bit before and after.

Post Reply
http://tworzymyatmosfere.pl/przescieradla-jedwabne-z-gumka/