Skip to content

Why isn't this trigger capturing my variables?

TRIGGER: ^You focus upon your pact and a terrifying visage of (.+) appears briefly in front of \w+, wreathed in flames\.$

if matches[2] == Skyrax then 
skyrax_balance = 1

elseif matches[2] == Rixil then 
rixil_balance = 1

elseif matches[2] == Eerion then 
eerion_balance = 1

elseif matches[2] == Arctar then 
arctar_balance = 1

elseif matches[2] == Scrag then
scrag_balance = 1

elseif matches[2] == Pyradius then
pyradius_balance = 1

elseif matches[2] == Palpatar then
palpatar_balance = 1 

elseif matches[2] == [[Nin'kharsag]] then
ninkharsag_balance = 1 

elseif matches[2] == Marduk then
marduk_balance = 1 

elseif matches[2] == Dameron then
dameron_balance = 1 

elseif matches[2] == Belial then
belial_balance = 1 

elseif matches[2] == Buul then
buul_balance = 1 

elseif matches[2] == "Cadmus" then
cadmus_balance = 1 

elseif matches[2] == Danaeus then
danaeus_balance = 1

elseif matches[2] == Lyncantha then 
lyncantha_balance = 1

elseif matches[2] == Hecate then 
hecate_balance = 1

elseif matches[2] == [[Jy'barrak]]then
golgotha_balance = 1

end

Comments

  • I feel like saying that 'because you wrote it' would be mean. I however am going to blame it on user error (I'm only kidding!) Would you mind posting what the line looks like when you summon one of the demons to possess you? It might help some!
  • :(

    <div>You focus upon your pact and a terrifying visage of Pyradius, the Demon Firelord appears briefly in</div><div>front of yourself, wreathed in flames.</div>
  • edited February 2019
    It is capturing it, issue is that you are trying to match a single name to the entire demon's name - Pyradius, the Demon Firelord is what is being captured, not Pyradius.

    try this instead:

    ^You focus upon your pact and a terrifying visage of (\w+), .* appears briefly infront of \w+, wreathed in flames$
  • Also, it's (.*) not the +
  • https://regexr.com/ is a good tool to use. The cheatsheet on the side helps explain the differences of things too. Positive and negative lookups are great, and imo, make use on non-capturing groups.

  • edited February 2019
    Naxxremis said:
    Also, it's (.*) not the +
    (.*) and (.+) both mean the same thing, generally speaking. Only difference is one will match regardless of if there's something to match or not.
    The other issue is you're not matching correctly. If you were to match a single name, you'd do if matches[2] == "Skyrax" for example. Easier to just do something like...
    </code>^You focus upon your pact and a terrifying visage of (\w+)<br><br>usedDemons = usedDemons or {}<br>usedDemons[matches[2]] = true<br></pre>Then you can just reference them with something like.</div><div><pre class="CodeBlock"><code>usedDemons = usedDemons or {} -- This is a failsafe to initialise the table in your aliases.<br>if not usedDemons.Hecate then<br>  <use hecate><br>elseif not usedDemons.Dameron then<br>  <use dameron><br>end<br>--etc<br>


  • Naxxremis said:
    Also, it's (.*) not the +
    (.*) and (.+) both mean the same thing, generally speaking. Only difference is one will match regardless of if there's something to match or not.
    The other issue is you're not matching correctly. If you were to match a single name, you'd do if matches[2] == "Skyrax" for example. Easier to just do something like...
    Being pedantic, * matches 0 or more of the previous thing, + matches 1 or more, ? matches 0 or 1. I wouldn't say that they mean the same thing as they have critical differences.
  • Rokas said:
    Naxxremis said:
    Also, it's (.*) not the +
    (.*) and (.+) both mean the same thing, generally speaking. Only difference is one will match regardless of if there's something to match or not.
    The other issue is you're not matching correctly. If you were to match a single name, you'd do if matches[2] == "Skyrax" for example. Easier to just do something like...
    Being pedantic, * matches 0 or more of the previous thing, + matches 1 or more, ? matches 0 or 1. I wouldn't say that they mean the same thing as they have critical differences.
    Being pedantic, the term 'generally speaking' refers to general usage when it comes to the majority of people who will use it. Thanks for repeating what I said, though.
  • Not appreciating the difference leads to unintended bugs that will cause more frustration because something will appear to work most of the time but have unexpected results.

    The difference between "general usage" and "carelessness" is thin with how you presented the information.
  • MathiausMathiaus Pennsylvania
    @Ocaris long time, but the reason why that wasn't working is because you didn't define the demon names as strings. You need the quotation marks around the names to make them strings, since the capture would match purely as a literal string as well.
    image
Sign In or Register to comment.