Welcome
This is a snippet that will highlight and change the color of everything in between (")'s in a /me message. I designed it for a guy who is into role-playing on IRC; if that person is you then this may be just what you are looking for.
on *:input:*:{
if ($1 == /me) {
;We must determine if there are more than 1 (")'s in the message, otherwise the script won't trigger
if ($numtok($2-,34) >= 2) {
set %x.number.of.words $numtok($2-,32)
set %x.check.each.word 0
set %x.quotation.search 1
set %x.swap.sides 1
;Loop to check each word to see if it matches a "
while (%x.number.of.words >= %x.check.each.word) {
inc %x.check.each.word 1
;If one of the words in the loop matches the first word with a quotation it will activate this.
if ($wildtok($2-,*"*,%x.quotation.search,32) == $gettok($2-,%x.check.each.word,32)) {
/*
To color each side of the quotation, we will need to explicetly determine which side, "left right",
of the quotation the text refers too. Since all quotes are assumed to have an end quote, the quotations
should be found in pairs; thus, %x.swap.sides will change from the left to the right side of the assumed quotes.
*/
if (%x.swap.sides = 1) {
if ($count($wildtok($2-,*"*,%x.quotation.search,32),") == 2) {
/*
However, if 2 quotes are found on the same word like "test" intead of "testing this" then
we will need to put color codes on either side of the word and so this will trigger.
*/
set %x-say %x-say �14 $+ $wildtok($2-,*"*,%x.quotation.search,32) $+ �6
}
else {
;Otherwise, just color the side corresponding to swap.sides
set %x-say %x-say �14 $+ $wildtok($2-,*"*,%x.quotation.search,32)
set %x.swap.sides 2
}
}
else {
;This bit will activate if swap.sides = 2, hence, the other side of the quotation.
if ($count($wildtok($2-,*"*,%x.quotation.search,32),") == 2) {
/*
Same as before, if there are more than 2 quotes on the same token, even if swap sides = 2
then we need to treat it differently and color both sides.
*/
set %x-say %x-say �14 $+ $wildtok($2-,*"*,%x.quotation.search,32) $+ �6
}
else {
;Otherwise, just color the side corresponding to swap.sides
set %x-say %x-say $wildtok($2-,*"*,%x.quotation.search,32) $+ �
}
set %x.swap.sides 1
}
inc %x.quotation.search 1
}
else {
/*
If the current token doesn't have a quotation, just add it back into this message to be built
back in as plain text
*/
set %x-say %x-say $gettok($2-,%x.check.each.word,32)
}
}
;perform your action below
me %x-say
;Its always a good idea to unset your var's when you are done ;)
unset %x.number.of.words
unset %x.check.each.word
unset %x.quotation.search
unset %x-say
unset %x.swap.sides
haltdef
}
}
}