Trouble with matches[2]

Post Reply
iueras
Posts: 3
Joined: Sat Jan 14, 2012 9:14 pm

Trouble with matches[2]

Post by iueras »

I hope someone can tell me what I'm doing wrong here, because I sure can't figure it out.

I have a simple perl regex trigger. The pattern is ^\w+ to grab the first word of the line that triggers it.

The code in the trigger is as simple as it can possibly get: echo(matches[2])

Debug console shows the following when the trigger is fired:

selectSection(0,35): line under current user cursor: North - All About Your Surroundings
P_begin(0/1282), P_end(35/1282) selectedText = North - All About Your Surroundings

match state 1/1 condition #0=true (0/2) regex=FG14BG0
Trigger name=Room Exits(^\w+) matched.
capture group #1 = <North>

selectSection(0,5): line under current user cursor: North - All About Your Surroundings
P_begin(0/1282), P_end(5/1282) selectedText = North

match state 1/1 condition #1=true (1/2) regex=^\w+
multiline trigger name=Room Exits *FIRES* all conditons are fullfilled. Executing script.
LUA: ERROR running script Room Exits (Trigger7) ERROR:Echo: wrong argument type
removing condition from conditon table.

Further debugging revealed the value of matches[2] is nil.

I must be missing something really obvious here, can anyone help out?

User avatar
Omni
Posts: 131
Joined: Fri Feb 12, 2010 10:26 am

Re: Trouble with matches[2]

Post by Omni »

(\w+)

iueras
Posts: 3
Joined: Sat Jan 14, 2012 9:14 pm

Re: Trouble with matches[2]

Post by iueras »

Thanks for the reply. That matches as well, but gets me 2 capture groups with the same matched word. The problem still remains, matches[2] is nil even though it matches a word and shows it in Capture Group #1.

EDIT:

I got it working, I wound up having to use multimatches[1][1] in place of matches[2]. I would think that that would be related to the fact that I am using multiline triggers with a color trigger as well the the perl regex matching, but I made a test trigger that did not use multiline and had no color matching and I still could not get any values to go into either matches[2] or matches[1] at all, always nil.

Has matches[2] been depreciated in 2.0-test4?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Trouble with matches[2]

Post by Vadi »

No, but you use multimatches for multiline triggers

Post Reply