Page 1 of 1
case insensitive temp triggers?
Posted: Wed Jun 16, 2010 12:23 pm
by abathur
I'm still getting acclimated. I looked for a while for an answer to this; I found where others have asked, but saw no answers. I'm looking to make a scratch temporary highlighting system for questing and reading through code. I made the following aliases below, and they work wonderfully--except they aren't case insensitive. I've tried /i and (i?) (?i) methods (with both tempTrigger and tempRegexTrigger,) with little success. Is there a way to do this that I'm overlooking?
Alias: ^highlight (.*)
local highLightVar = matches[2]
local highLightReg = matches[2]
local tempHighlight = tempTrigger(highLightReg, [[selectString("]] .. highLightVar .. [[", 1) setFgColor(0,0,0) setBgColor(255,200,200) resetFormat()]])
tempHighlights[highLightVar]=tempHighlight
echo("Now highlighting: ")
echo(highLightVar)
echo("\n")
Alias ^unhighlight (.*)
local killThisName = matches[2]
local killThisID = tempHighlights[killThisName]
killTrigger(killThisID)
table.remove(tempHighlights, killThisID)
echo("Stopped highlighting: ")
echo(killThisName)
echo("\n")
Re: case insensitive temp triggers?
Posted: Wed Jun 16, 2010 12:44 pm
by chalraes
Try this:
local tempHighlight = tempRegexTrigger("(?i:"..highLightReg..")", [[selectString("]] .. highLightVar .. [[", 1) setFgColor(0,0,0) setBgColor(255,200,200) resetFormat()]])
Re: case insensitive temp triggers?
Posted: Wed Jun 16, 2010 11:14 pm
by abathur
Trigger name=19((?i:sauron)) matched.
capture group #1 = <Sauron>
line under current user cursor: 9079#:Sauron
(Arch Wizard)
LUA OK script 19 (Trigger19) ran without errors
That's matching both versions, it looks like, but the highlight still only works on the version originally input. I tried changing the selectString's first arg to the same, but I either mucked it up or it isn't working. Probably the former.
Re: case insensitive temp triggers?
Posted: Thu Jun 17, 2010 7:56 am
by Heiko
The highlight only works for the version that triggered the *first* script compilation. TempTrigger scripts only get compiled once in their lifetime. When the trigger fires again Mudlet does not recompile the script for performance reasons.
Consequently, you need to change your script and use a variable instead of an absolut string value for your highlighting target. -> instead of concatenating the value of highLightVar as a constant value you should use the variable content _G["highLightVar"] in your tri gger script.