Help with a prompt trigger

Post Reply
aloc_acoc
Posts: 12
Joined: Mon Oct 19, 2009 11:12 pm

Help with a prompt trigger

Post by aloc_acoc »

I've been having a lot of trouble with trying to capture certain items on a trigger of mine. Currently, my trigger pattern looks like this:

Code: Select all

^(\d+)h\, (\d+)m\, (\d+)e\, (\d+)w ([cexkdb@]*)\-
And my code looks like this:

Code: Select all

if string.find(matches[5],"e") == nil 
then equilibrium = 0 
else equilibrium = 1
end;
if string.find(matches[5],"x") == nil 
then balance = 0 
else balance = 1
end;
I want to make it so if the "e" in that last chunk of the trigger pattern is not present, then the equilibrium variable will be set to 0. If the "e" is present, then the variable will be set to 1. Likewise with the "x" and the balance variable. The problem is though, it's currently always reading that the "e" and "x" are not present, because it the balance and equilibrium values are always shown to be 0. However, when I debug it, I am shown that the "e" and "x" are being caught by the trigger in the 5th match position:

Code: Select all

Prompt Tracking(^(\d+)h\, (\d+)m\, (\d+)e\, (\d+)w ([cexkdb@]*)\-) matched.
capture group #0 = <2742h, 2555m, 12580e, 13600w ex->
capture group #1 = <2742>
capture group #2 = <2555>
capture group #3 = <12580>
capture group #4 = <13600>
capture group #5 = <ex>
Any advice for me?

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

Re: Help with a prompt trigger

Post by Heiko »

Code: Select all

if string.find(matches[6],"e") == nil then
    equilibrium = 0
else 
    equilibrium = 1
end
matches[1] = the entire match
matches[2] = capture group #1
...
matches[6] = capture group #5

Post Reply