I was recently trying to script something similar to this and came up with a solution like this. If I get the jist of what you're trying to do I hope this helps
on ^*:TEXT:*:#:{
if ($highlight) && ($highlight($1-) != $null) {
echo -tml $chan $+(<,$nick,>) $+ $highlight(color) $+ $1-
}
else {
echo -tm $chan $+(<,$nick,>) $1-
}
haltdef
}
The if statement checks if highlighting is enabled then checks if the string $1- matches the highlighted words. If it does it will echo with the highlight function and highlight it in the specified colour.
If not it will echo normally.