Highlighting one Variable

Post Reply
icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Highlighting one Variable

Post by icesteruk »

Hey, im wanting to highlight my TARGET variable a certain color so I can better see it when im hunting etc but i can only set it so it captures Goblin or goblin, not if its them both, im using title().. any clue how I can change it to capture both caps and no caps?

if i use lower() it only captures 'goblin' and title() only captures 'Goblin' ....

-----------------------------
target = string.title(matches[2])

if id then
killTrigger(id) end id = tempTrigger(target, [[selectString("]] .. target .. [[", 1) fg("gold") resetFormat()]])

--------------------------------------
is what im using..

Golem
Posts: 30
Joined: Thu Feb 07, 2013 6:46 pm

Re: Highlighting one Variable

Post by Golem »

There are multiple solutions to your problem, but one of the simplest is I think using an case insensitive regex.

For example:
Code: [show] | [select all] lua
tempRegexTrigger("(?i)orc", ...)
will work for patterns like Orc, oRc, ORC, etc.

Good luck, G.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Highlighting one Variable

Post by icesteruk »

hmm no offense but that made no sense :/

Golem
Posts: 30
Joined: Thu Feb 07, 2013 6:46 pm

Re: Highlighting one Variable

Post by Golem »

In what way? :) Do you want the exact code you need to solve your problem? Which part of my explanation is too convoluted?
What I suggested was simply replacing your tempTrigger with tempRegexTrigger and beforehand adding a (?i) in front of the targets name.

If you need more info on regular expressions there are tutorials on the web. If you think this solution is too complex then you may simply create two tempTriggers, one for uppercase, the other for lowercase.

Once again, good luck, G.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Highlighting one Variable

Post by icesteruk »

noo I did what you said, but its not highlighting the lower case names.... my code does go into an Alias... alo the 'target' is a variable, not a 'name' .... :?

Golem
Posts: 30
Joined: Thu Feb 07, 2013 6:46 pm

Re: Highlighting one Variable

Post by Golem »

I would have to see your modified code to answear as to why it is not working but my guess would be that the coloring code also needs to be changed - try selecting the matches of the temporary trigger instead of the target variable - remember that the match might be upper or lower case.

As to my use of "name" - i was referring to the targets name such as "orc", "goblin" or whatever the target variable is set to. Adding "(?i)" in front of targets value tells the regex trigger to ignore character case.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Highlighting one Variable

Post by icesteruk »

if id then
killTrigger(id) end id = tempRegexTrigger("(?i)" .. target, [[selectString("]] .. target .. [[", 1) fg("gold") resetFormat()]])


-- was what I changed it too... :?

Golem
Posts: 30
Joined: Thu Feb 07, 2013 6:46 pm

Re: Highlighting one Variable

Post by Golem »

Try replacing selectString("]] .. target .. [[", with selectString(matches[2],

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Highlighting one Variable

Post by icesteruk »

ok now im really confused.. replace what with what :? this is just going round in circles I'll just keep it as it is...

thanks anyway

Golem
Posts: 30
Joined: Thu Feb 07, 2013 6:46 pm

Re: Highlighting one Variable

Post by Golem »

Right, it seems suggestions are not the way to go. No problem. Here is the full solution, simply paste this in:
Code: [show] | [select all] lua
target = matches[2]

if id then
	killTrigger(id) 
end 

id = tempRegexTrigger("(?i)" .. target, 
	[[
		selectString(matches[1], 1) 
		fg("gold") 
		resetFormat()
	]])
Good luck, G.

Post Reply