Page 1 of 1
Help with color trigger
Posted: Fri Aug 13, 2021 1:01 am
by Puckster
I found some discussion on this topic on old posts, but I did not find a solution.
I want to trigger on the color of a whole line (or even just the first few chars).
The following trigger fires if ANY of the characters in the line are are the trigger color.
- Color trigger.PNG (16.09 KiB) Viewed 6856 times
Any thoughts?
Re: Help with color trigger
Posted: Fri Aug 13, 2021 1:26 am
by demonnic
Try something like this
-- checks the first five characters to see if they're yellow
-- if you want to check the whole line, change 5 to #line ie "for i=1,#line do"
local isYellow = true
for i=1,5 do
selectSection(i-1,i)
if not isAnsiFgColor(11) then
isYellow = false
break
end
end
deselect()
if isYellow then
echo("It's yellow!\n")
end
Re: Help with color trigger
Posted: Fri Aug 13, 2021 1:37 am
by Puckster
Hmm... not getting it to work. What should I put for the trigger to execute that code? I tried regex .*, but that didn't work.
Re: Help with color trigger
Posted: Fri Aug 13, 2021 3:50 am
by demonnic
Still a color trigger for the color yellow, all the code is doing is checking the first few characters of the line to make sure those are in yellow in particular. And are you getting an error or something?
Re: Help with color trigger
Posted: Fri Aug 13, 2021 4:05 am
by demonnic
ahhh, use 7 rather than 11
Re: Help with color trigger
Posted: Fri Aug 13, 2021 2:34 pm
by Puckster
Aha! Thank you! That explains it.
That last response prompted me to look here
https://wiki.mudlet.org/w/Manual:UI_Functions, where I found this:
Code: Select all
0 = default text color
1 = light black
2 = dark black
3 = light red
4 = dark red
5 = light green
6 = dark green
7 = light yellow
8 = dark yellow
9 = light blue
10 = dark blue
11 = light magenta
12 = dark magenta
13 = light cyan
14 = dark cyan
15 = light white
16 = dark white
Very helpful! Especially since the number are differnt that in the coloro trigger:
- ANSI Colors.PNG (9.46 KiB) Viewed 6827 times
Re: Help with color trigger
Posted: Fri Aug 13, 2021 2:55 pm
by demonnic
Yeah, I'm not sure why those numbers don't match up, but that's what caught me out.
Re: Help with color trigger
Posted: Fri Aug 13, 2021 3:26 pm
by Puckster
Me too. Now we know!
Re: Help with color trigger
Posted: Sat Aug 21, 2021 12:15 pm
by SlySven
Very helpful! Especially since the number are differnt that in the coloro trigger:
The colour selection dialogues for the colour triggers are referring to the ANSI 256-colour indexes (which are what the MUD Game Server will be sending) - but the list you are quoting came from a long standing function
tempColorTrigger(...) which had that choice of numbers baked in back in the mists of time. Unfortunately they are NOT ANSI codes - so to get around that I added
tempAnsiColorTrigger(...) which does use those numbers {as well as a couple of special case ones with negative values...!}
Re: Help with color trigger
Posted: Sat Aug 21, 2021 12:28 pm
by Vadi
Updated the docs so we find the alternative easier =)