Page 1 of 3

Text Coloring

Posted: 20 Aug 2013 22:40
by Gub
Ability to change the color of a word rather than the whole line.

Re: Wishlist

Posted: 20 Aug 2013 22:49
by Eowul
Gub wrote:Ability to change the color of a word rather than the whole line.
Can you give me a "use case" so I can figure out how to best add this?

Re: Text Coloring

Posted: 20 Aug 2013 22:54
by Laurel
It looks like it is in a prime condition/little worn down/etc.

Re: Text Coloring

Posted: 20 Aug 2013 22:55
by Gub
Sure. If I want to highlight the word "peculiar" or "unusual" rather than highlighting the entire line. I'd like it to look something like this:

You get an unusual black robe
rather than:
You get an unusual black robe.

Re: Text Coloring

Posted: 20 Aug 2013 23:12
by Eowul
Gub wrote:Sure. If I want to highlight the word "peculiar" or "unusual" rather than highlighting the entire line. I'd like it to look something like this:

You get an unusual black robe
rather than:
You get an unusual black robe.
Awefull choice in colors .. Anyway, you would then be thinking of something like gwc.output.colorText("unusual", foreground, background) ?

Re: Text Coloring

Posted: 21 Aug 2013 00:49
by Gub
Hah, I agree, it looks horrible.

Yeah, thats it exactly.

Re: Text Coloring

Posted: 21 Aug 2013 00:55
by Gub
Can you expose some more of the internal API so we can write our own libraries that could be included into the system? Rather than requesting the method call you just suggested, I feel like users should be able to write them and then have them included (after review) into a standard library. Or can we already do this? Thoughts?

Re: Text Coloring

Posted: 21 Aug 2013 07:03
by Eowul
Gub wrote:Can you expose some more of the internal API so we can write our own libraries that could be included into the system? Rather than requesting the method call you just suggested, I feel like users should be able to write them and then have them included (after review) into a standard library. Or can we already do this? Thoughts?
Internal API's should remain exactly that, internal API's, otherwise any change we might do might break users triggers and aliases. That's why I added the script API, as something that remains consistent throughout releases. Ofcourse you are welcome to suggest functionality to add to it, if it's usefull for more people then I am more then happy to include it. Besides, with javascript you should already be able to do a lot of thing.

Re: Text Coloring

Posted: 21 Aug 2013 19:20
by Gub

Code: Select all

var src_str=$("#mudoutput .line").last().html();
var term = "unusual";
term = term.replace(/(\s+)/,"(<[^>]+>)*$1(<[^>]+>)*");
var pattern = new RegExp("("+term+")", "i");
src_str = src_str.replace(pattern, "<mark>$1</mark>");
src_str = src_str.replace(/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/,"$1</mark>$2<mark>$4");
$("#mudoutput .line").last().html(src_str);
Ok ignore what I said last time, this is what I meant: The code above shows a way to implement what I was speaking about. I think there are better ways of implementing this, but it gets the job done. The critical part here is the '$("#mudoutput .line").last()' which allows you to grab the last output line from the game. I don't see that in the documentation, and to me, this is fairly critical. If people want to use it, they can. If you would like to include it in your script_api, you can. Right now there is no easy way to find things like "#mudoutput .line" and to then share the trigger I've created. That is all I meant. Do what you will with all this, its your baby, and its a very nice one! Again, kudos on your creation,

Re: Text Coloring

Posted: 21 Aug 2013 22:58
by Rincon
Wow. After playing genesis all these years I still don't have the finest clue what do all these dots and other funny symbols mean! :)