Hello everyone,
I am trying to make a temp trigger that matches on a target, however at the same time it must exclude any lines that contain another word within them.
I have tried:
tempTrigger(target,[[if not string.match(matches[1], "exclude_word") then go_to_function() end]])
This is not working though either due to a syntax error, or I am going about it wrong. Any help would be appreciated.
problem with temptriggers and excluding
Re: problem with temptriggers and excluding
If it was a syntax error, it would show up in your error view. Does it?
Anyways, the problem here is this: matches[1] is not the whole line your temp trigger matches on, but simply the part matched by the trigger pattern, in this case: target. So the string.match() you have there would only actually match if your target was your exclude_word. What you probably want is:
tempTrigger(target,[[if not string.match(line, "exclude_word") then go_to_function() end]])
Anyways, the problem here is this: matches[1] is not the whole line your temp trigger matches on, but simply the part matched by the trigger pattern, in this case: target. So the string.match() you have there would only actually match if your target was your exclude_word. What you probably want is:
tempTrigger(target,[[if not string.match(line, "exclude_word") then go_to_function() end]])
Re: problem with temptriggers and excluding
Thank you that fixed it all, very much appreciated Iocun!