Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Jscript ➜ triggers + scripting, how to get a script to highlight text

triggers + scripting, how to get a script to highlight text

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Hexed   (6 posts)  Bio
Date Sat 06 Sep 2003 09:09 AM (UTC)
Message

I'm trying to write a script which converts text in the mud window to a certain colour depending on what the text is.

The input from the mud looks something like this

armor good blindness incompetent

cancellation incompetent cure blindness incompetent

cure critical incompetent cure disease incompetent

etc etc
except the 'incompetent' on the second line is tacked on the end of the first line.

it's a big block of text basically.

I have two main problems, how to input the block into a trigger with wildcards for the 'incompetent' etc bits.

the only way I could currently think of is to have a seperate trigger for each line.

Secondly how to get the script to change the colour.

ie switch (name)
{
case "incompetent":
<make text blue in mud window>
break;

case "consumate":
< make text yellow in mud window>
break;
default:

}

cheers.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 06 Sep 2003 09:25 AM (UTC)
Message
I'm not sure if the requirement is more complex than this, but the simple solution is:

Make the trigger match the single word, eg. 'incompetent'

Check: regular expression

Set: change colour to: the colour you want

Check "keep evaluating" if there is likely to be more than one on the same line

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hexed   (6 posts)  Bio
Date Reply #2 on Sat 06 Sep 2003 09:29 AM (UTC)
Message
the problem is there is an entire range of descriptions for how good you are at a skill, they start at incompetent and range through to consumate . eg incompetent , indept , fumbling , learned, skilled .. etc.

thats why I need the case statement.
So it changes the colour according to which one of these is displayed.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 06 Sep 2003 10:23 AM (UTC)
Message
So, make one trigger each.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hexed   (6 posts)  Bio
Date Reply #4 on Sat 06 Sep 2003 10:39 AM (UTC)
Message
I *could* , but unfortunately this would mean over 3400 seperate triggers to cover all the situations.

Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #5 on Sun 07 Sep 2003 12:24 AM (UTC)
Message
I see. So you were planning to have 3400 items in your switch statement?

Let's assume you don't want to have 3400 different colours, a sensible assumption as I believe the human eye can only distinguish around 200 colours in a single picture.

Thus, you could have one trigger per colour (say you have 200 colours) using regular expressions and the "or" symbol (|).

eg.

match on: armor|good|blindness|incompetent

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hexed   (6 posts)  Bio
Date Reply #6 on Sun 07 Sep 2003 04:09 AM (UTC)
Message
Firstly I apologise for not being very clear in my first post, so here follows a full description of my problem.

Firstly a big thank you to any that actually bothers to read all this :P

and an even better thankyou to anyone that attempts to help me.


Ok.

Basically , I want to change to colour of certain text in my mud window.



The text that I want to change the colours in is in this table (the 'prac' command) :

armor good blindness incompetent
cancellation incompetent cure blindness incompetent
cure critical inept cure disease incompetent
cure light inept cure poison incompetent
cure serious masterful curse incompetent
dispel magic incompetent energy drain incompetent
fireproof incompetent fly incompetent
heal incompetent pass door incompetent
plague incompetent poison competent
protection good good refresh incompetent
sanctuary incompetent slow incompetent
summon incompetent weaken consummate
word of recall incompetent axe incompetent
dagger incompetent flail incompetent
mace adequate polearm incompetent
shield block consummate sword consummate
bash incompetent berserk incompetent
disarm unseasoned dodge consummate
enhanced damage consummate hand to hand consummate
parry consummate second attack consummate
third attack learned fast healing mediocre
pick lock incompetent scrolls incompetent
staves inept wands inept
recall mean



The words after the skill (hereafter refered to as descriptive words) can be any of the following :

incompetent
inept
untried
fumbling
unseasoned
mediocre
mean
average
adequate
good
skilled
learned
competent
proficient
expert
superb
adept
masterful
consumate.


As I get better at any given spell skill, the words change to one up the list.

I want to change the colour of the descriptive words, into some sort of rainbow scheme where incompetent is at one end and consumate is at the other.

At the moment I have though of a few solutions to this problem .

1. Have 34 seperate triggers, ie one for each line of the descriptive table, that all parse into the same function in a script.

For example : armor * blindness *

The function would have a 2 identical case statements (one for each of the wildcards) , so depending on which descriptive word was in the wildcard , a different color would appear in the table back in the mud window.

Pro's of this solution are that the same function could be used for all the triggers.

Con's are that I don't know how to change the colour of a word in the mud world from a function.

===========================================================

2. Parse the entire block of text into a function, tokenize the string.

then use a loop and a case statement , to change all the words to the right colour.

output back to the mud.

Pro's : most efficient way of doing the whole thing

Con's : Same as in solution 1 +
I don't know how to parse the entire block of text

===========================================================

3. Create a seperate trigger for each situation.

For example the first line

armor good blindness incompetent

As their are 19 seperate descriptive words, and 2 of them on a line , that leaves (19 x 19) x 2 = 722 combinations that have to be covered. I'm fairly sure my math is correct there, but I may be wrong , please correct me if I am .

Assuming I'm correct, that makes 722 seperate triggers for each line, and as their are 34 lines in the table... well you do the math.

Pro's : I know how to create this solution
Con's : I don't think it's worth it.

===========================================================

*whipes brow* , that about covers it.



Also, Nick would it be possible to get a list of which functions are inbuilt to the world ?

ie setVariable , getVariable etc.

This would prove most useful for future scripts aswell as this one.










Top

Posted by Hexed   (6 posts)  Bio
Date Reply #7 on Sun 07 Sep 2003 04:42 AM (UTC)
Message

ok the last bit about having the list of function...

*STOMP self*
Just found the list.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #8 on Sun 07 Sep 2003 04:56 AM (UTC)
Message
Ah, 19, eh? That is better.

I would make 19 triggers, one for each skill level, matching a regular expression, and "repeat on same line", and "keep evaluating". That will colour both words appropriately on the one line.

Then, assuming these words might appear elsewhere, and you don't want them so coloured (is this true?) then put all 19 triggers into one trigger group, and enable that group when it sees a practice command, and disable it when the practice command finishes.

One approach would be to have a trigger that matches:

armor * blindness *

- assuming that always comes first and is always there. Make that one enable the group, have it have a low sequence number so it is done first, and "keep evaluating" so the colours on that line are changed.

Then take the last line:

recall *

Make it do the opposite. Make it disable the group, and have a high sequence number so the colouring is done first, and then the group is disabled.

That should do it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hexed   (6 posts)  Bio
Date Reply #9 on Sun 07 Sep 2003 05:02 AM (UTC)
Message


whee! *cheers*

I *knew* there was an easier way..
thanks heaps for that Nick.

Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


29,412 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.