View unanswered posts | View active topics It is currently 23 Jan 2018 06:07

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.



Reply to topic  [ 21 posts ]  Go to page 1, 2, 3  Next
Marking in colour one word 
Author Message
Wanderer
User avatar

Joined: 23 Sep 2014 20:33
Posts: 67
Hi
Do any of you knows how to mark in colour based on t pattern one word only and not a whole line?


04 Oct 2015 21:00
Profile
Wizard
User avatar

Joined: 28 Sep 2015 16:42
Posts: 45
You can change the colour of a text phrase by using a <span> element with a color style attribute

* Click on settings
* Click on Triggers Tab
* Click on Add new trigger
* Click the Regexp button for Trigger Type
* Enter Pattern: You find a (.*)[\.|!]
* Click Javascript for the Script Type
* Enter the below code
Code:
gwc.output.replace(args[0], 'Found: <span style="color: rgb(0,255,0)">' + args[1] + '</span>', true);
gwc.output.color('#888888');

* Click Save
* Close settings popup
* Go herbing

In the above code, args[0] is the full text of the line that matches the regexp pattern. args[1] is captured text from (.*) that was found between "You find a " and either a "!' or a "."


07 Oct 2015 14:18
Profile
Wanderer
User avatar

Joined: 23 Sep 2014 20:33
Posts: 67
Many, Many thank Britanica Your example is very useful. But puting my question I was thinking about somethin else. I wanted to mark one word only.
Lets imagine I love to collect diamonds. . After w day of killing I have 100 of gems. But to quick see how many of diamonds I have I would like to mark them in colour. The same apply to quick check if a mob wield or wear looked equipment. Do you know how to do it?


09 Oct 2015 17:06
Profile
Wizard
User avatar

Joined: 28 Sep 2015 16:42
Posts: 45
To change the colour of individual words you can use the following

Trigger Pattern: (.*)

Code:
var hilites = ['diamond', 'wielding', 'wearing'];
hilites.forEach( function(word) {
    gwc.output.replace(word, '<span style="color: rgb(255,255,0)">' + word + '</span>', true);
});


This will result in the output looking like


The deadly slight male elf has the look of wisdom in his eyes, a wisdom which is only learned through age. Faint wrinkles line his face. Nonetheless, he still appears agile enough.
He is wearing a decorated purple robe and a plain silver tunic.
He has pointed ears.
He is wielding an exceptional shiny shortsword in his right hand.
He is nodding solemnly.
He is extremely tall and very skinny for an elf.
He looks like the image of perfection.
He seems to be feeling very well.


If this is not what you had in mind, can you provide a sample of the output you are trying to achieve?


10 Oct 2015 01:18
Profile
Expert
User avatar

Joined: 16 Nov 2014 23:10
Posts: 283
I love your explanations, with scripts :-)

I understand how to work the app and triggers now ! (somewhat)


Just one question, that makes me wonder...

Another example had a trigger like :
Trigger: ^There (are|is) (.*) obvious (exits|exit): (.*)[\.]

Would it not be safer, to use the trigger :(diamond|wielding|wearing)

I just forgot to tick javascript after the regex triggger (.*), which gives an eternal loop in the app, as it spams in resonse to what :-) That trigger seems dangerous to me.
I don´t know how it works, but i would image it would slow the entire thing down too, with checking everything.


29 Oct 2015 14:50
Profile
Wizard
User avatar

Joined: 28 Sep 2015 16:42
Posts: 45
Alisa wrote:

Would it not be safer, to use the trigger :(diamond|wielding|wearing)
...
I don´t know how it works, but i would image it would slow the entire thing down too, with checking everything.


You are correct on both counts. Specifically looking for individual words is safer and faster

I did update my trigger to use a similar version a few hours after posting as the client seamed to be hanging a little. I also had a larger list of words to hilite and each line is checked for each word meaning multiple passes on each line received.

It also means you can get rid of the array of names and changes the body of the trigger to:
Code:
gwc.output.replace(args[1], '<span style="color: rgb(255,255,0)">' + args[1] + '</span>', true);


Last edited by britanica on 30 Oct 2015 10:02, edited 2 times in total.



30 Oct 2015 09:47
Profile
Wizard
User avatar

Joined: 28 Sep 2015 16:42
Posts: 45
------------


30 Oct 2015 09:48
Profile
Expert
User avatar

Joined: 16 Nov 2014 23:10
Posts: 283
Cool :-)

Love understanding stuff!

Thanks.


30 Oct 2015 10:06
Profile
Wanderer
User avatar

Joined: 23 Sep 2014 20:33
Posts: 67
Britanica

Your tips were super up today. Last Cotillion's modification with "Automatically disable triggers found to be looping" has broke down this trig. The trig looked like:

Code:
Type: regexp
Pattern: (.*)

code:
var hilites = ['wielding', 'wearing'];
hilites.forEach( function(word) {
    gwc.output.replace(word, '<span style="color: rgb(127,255,0)">' + word + '</span>', true);
});

Unfortunately the last modification/improvement introduced yesterday disable this trig after some time(10-20 min), even if I dont exa anyone. I'm not sure if this any looping system works as planned but we will need to find another solution to mark one word with color.


21 Nov 2015 02:46
Profile
Expert
User avatar

Joined: 16 Nov 2014 23:10
Posts: 283
the (.*) trigger hits every line, so i guess it gets detected as a loop.(triggering on every output from mud)

If you do the pattern as

(wielding|wearing)

and the command as

gwc.output.replace(args[1], '<span style="color: rgb(255,255,0)">' + args[1] + '</span>', true);

It should be good :-)


21 Nov 2015 12:16
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 21 posts ]  Go to page 1, 2, 3  Next

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.