case insensitive temp triggers?

Post Reply
abathur
Posts: 3
Joined: Mon Jun 14, 2010 2:03 pm

case insensitive temp triggers?

Post 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 (.*)
Code: [show] | [select all] lua
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 (.*)
Code: [show] | [select all] lua
local killThisName = matches[2]
local killThisID = tempHighlights[killThisName]
killTrigger(killThisID)
table.remove(tempHighlights, killThisID)
echo("Stopped highlighting: ")
echo(killThisName)
echo("\n")

chalraes
Posts: 10
Joined: Mon Jun 14, 2010 10:48 pm

Re: case insensitive temp triggers?

Post by chalraes »

Try this:
Code: [show] | [select all] lua
local tempHighlight = tempRegexTrigger("(?i:"..highLightReg..")", [[selectString("]] .. highLightVar .. [[", 1) setFgColor(0,0,0) setBgColor(255,200,200) resetFormat()]])

abathur
Posts: 3
Joined: Mon Jun 14, 2010 2:03 pm

Re: case insensitive temp triggers?

Post 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.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: case insensitive temp triggers?

Post 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.

Post Reply