Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Why isn't this trigger capturing my variables?

OcarisOcaris Member Posts: 33
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

  • NaxxremisNaxxremis Member Posts: 24
    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!
  • OcarisOcaris Member Posts: 33
    :(

    You focus upon your pact and a terrifying visage of Pyradius, the Demon Firelord appears briefly infront of yourself, wreathed in flames.
  • NaxxremisNaxxremis Member Posts: 24
    edited February 24
    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$
  • NaxxremisNaxxremis Member Posts: 24
    Also, it's (.*) not the +
  • RokasRokas Member Posts: 167 ✭✭✭
    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.

    Jalaras
  • KalynthariKalynthari Member Posts: 280 ✭✭✭
    edited February 24
    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...
    ^You focus upon your pact and a terrifying visage of (\w+)

    usedDemons = usedDemons or {}
    usedDemons[matches[2]] = true
    Then you can just reference them with something like.
    usedDemons = usedDemons or {} -- This is a failsafe to initialise the table in your aliases.
    if not usedDemons.Hecate then
    <use hecate>
    elseif not usedDemons.Dameron then
    <use dameron>
    end
    --etc


  • RokasRokas Member Posts: 167 ✭✭✭
    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.
  • KalynthariKalynthari Member Posts: 280 ✭✭✭
    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.
    Rokas
  • RokasRokas Member Posts: 167 ✭✭✭
    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.
    Javon
  • MathiausMathiaus PennsylvaniaMember Posts: 1,030 ✭✭✭✭
    @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.