Mudlet Coding Problem for shield tracking

So I'm trying to get some coding together so I can get a trigger for a cecho that tells me when someone or something puts up a pentagram or circle and when that pentagram/circle goes down. So far I have something, but I'm not sure why it isn't working. I need one for players, and one for hunting. (Not sure if they will be different.) I use itar <creature name> for targetting while hunting and tar <player> for targetting during combat.

For hunting I have this

for line 0: ^(.+) mutters and traces a cobalt blue pentagram in the air that remains hovering before (him|her)\.$
for line 1: ^Spreading (his|her) arms wide\, (.+) spins clockwise and a shimmering white orb springs up around (him|her)\.$

I have both set to perl regex

For the code, I have:

if string.lower("" .. matches[2] .. "") == string.lower("" ..itar.. "") then deleteLine()

cecho("\n <medium_violet_red> ------------------------------------------------ \n")

cecho("\n <medium_violet_red> | TARGET SHIELDUP TARGET SHIELDUP |\n")

cecho("\n <medium_violet_red> ------------------------------------------------ \n")

end 

Comments

  • edited February 2014
    Try these patterns:

    ^(\w+) mutters and traces a cobalt blue pentagram in the air that remains hovering before (him|her)\.$
    ^Spreading .+? arms wide\, (\w+) spins clockwise and a shimmering white orb springs up around (him|her)\.$

    Try this code:

    if string.lower(matches[2]) == string.lower(itar) then
    deleteLine()

    cecho("\n <medium_violet_red> ------------------------------------------------ \n")

    cecho("\n <medium_violet_red> | TARGET SHIELDUP TARGET SHIELDUP |\n")

    cecho("\n <medium_violet_red> ------------------------------------------------ \n")

    end
  • edited February 2014
    The matches[2] you had for the line 1 trigger would have been (his|her), I think you can prevent it from matching with (?:his|her) but I'm not 100% sure without looking at my system, however I know .+? will work and won't return matches[2].
  • Chade said:
    Try these patterns:

    ^(\w+) mutters and traces a cobalt blue pentagram in the air that remains hovering before (him|her)\.$
    ^Spreading .+? arms wide\, (\w+) spins clockwise and a shimmering white orb springs up around (him|her)\.$

    Try this code:

    if string.lower(matches[2]) == string.lower(itar) then
    deleteLine()

    cecho("\n <medium_violet_red> ------------------------------------------------ \n")

    cecho("\n <medium_violet_red> | TARGET SHIELDUP TARGET SHIELDUP |\n")

    cecho("\n <medium_violet_red> ------------------------------------------------ \n")

    end
    I tried the patterns and codes you gave without any luck. Any other possible solutions?
  • UshaaraUshaara Schrödinger's Traitor
    Chade's should work against other players I would think, but for hunting the '==' is going to test for exact equality, which won't necessarily be the case.

    Eg, if your target is 'merian', you can have the different types of merian, 'A merian bravo mutters and traces...'

    Try

    if string.find(matches[2], itar) then
    YOUR CODE HERE
    end

  • Ushaara said:
    Chade's should work against other players I would think, but for hunting the '==' is going to test for exact equality, which won't necessarily be the case.

    Eg, if your target is 'merian', you can have the different types of merian, 'A merian bravo mutters and traces...'

    Try

    if string.find(matches[2], itar) then
    YOUR CODE HERE
    end

    Still nothing. I am currently using

    Patterns:

    ^(\w+) mutters and traces a cobalt blue pentagram in the air that remains hovering before (him|her)\.$
    ^Spreading .+? arms wide\, (\w+) spins clockwise and a shimmering white orb springs up around (him|her)\.$

    Code:

    if string.find(matches[2], itar) then

    deleteLine()

    cecho("\n <medium_violet_red> ------------------------------------------------ \n")

    cecho("\n <medium_violet_red> | TARGET SHIELDUP TARGET SHIELD UP |\n")

    cecho("\n <medium_violet_red> ------------------------------------------------ \n")

    end


    Is everything correct? 



  • UshaaraUshaara Schrödinger's Traitor
    (\w+) will only match a single word, so I was going off your original post in my reply.
    Try
    
    ^(.+) mutters and traces a cobalt blue pentagram in the air that remains hovering before (?:him|her)\.$
    ^Spreading (?:his|her) arms wide, (.+) spins clockwise and a shimmering white orb springs up around (?:him|her)\.$
    
    local str = string.lower(matches[2])
    if string.find(str, itar) or string.find(str, tar) then
    deleteLine()
    cecho("\n  ------------------------------------------------ \n")
    cecho("\n  | TARGET SHIELDUP TARGET SHIELD UP |\n")
    cecho("\n  ------------------------------------------------ \n")
    end
    
  • Ushaara said:
    (\w+) will only match a single word, so I was going off your original post in my reply.
    Try
    ^(.+) mutters and traces a cobalt blue pentagram in the air that remains hovering before (?:him|her)\.$
    ^Spreading (?:his|her) arms wide, (.+) spins clockwise and a shimmering white orb springs up around (?:him|her)\.$
    
    local str = string.lower(matches[2])
    if string.find(str, itar) or string.find(str, tar) then
    deleteLine()
    cecho("\n  ------------------------------------------------ \n")
    cecho("\n  | TARGET SHIELDUP TARGET SHIELD UP |\n")
    cecho("\n  ------------------------------------------------ \n")
    end
    
    Still nothing :(. If there is nothing wrong with the cecho, could there be something wrong with the variable that I set it to for targetting? For targetting I have

    ^itar (.+)$

    itar = matches[2]

    echo ("Target: " ..itar)

  • edited February 2014
    Could always use matches[1] instead, to check the entire line for your target. Since it's only going to looking at those specific lines, anyway.
    (Just tested this to verify that it does indeed work)
    eg:

    local str = string.lower(matches[1])
    if string.find(str, itar:lower()) then deleteLine()
    cecho("\n<red> ----------------------------------\n") cecho("\n<red> | TARGET SHIELDUP TARGET SHIELD UP |\n")
    cecho("\n<red> ----------------------------------\n") end
    Using these lines:
    ^.* mutters and traces a cobalt blue pentagram in the air that remains hovering before (\w+)\.$
    ^Spreading (\w+) arms wide, .* spins clockwise and a shimmering white orb springs up around (\w+)\.$
    ^Eyes glowing red, .* bellows and a shield of protection flickers into view around (\w+) form\.$
  • UshaaraUshaara Schrödinger's Traitor
    edited February 2014
    Regin said:
    Ushaara said:
    (\w+) will only match a single word, so I was going off your original post in my reply.
    Try
    ^(.+) mutters and traces a cobalt blue pentagram in the air that remains hovering before (?:him|her)\.$
    ^Spreading (?:his|her) arms wide, (.+) spins clockwise and a shimmering white orb springs up around (?:him|her)\.$
    
    local str = string.lower(matches[2])
    if string.find(str, itar) or string.find(str, tar) then
    deleteLine()
    cecho("\n  ------------------------------------------------ \n")
    cecho("\n  | TARGET SHIELDUP TARGET SHIELD UP |\n")
    cecho("\n  ------------------------------------------------ \n")
    end
    
    Still nothing :(. If there is nothing wrong with the cecho, could there be something wrong with the variable that I set it to for targetting? For targetting I have

    ^itar (.+)$

    itar = matches[2]

    echo ("Target: " ..itar)

    Just did a quick test of the code I provided. Make sure that you have declared -both- of your itar and tar variables, and that they're in lowercase and it should work.
  • Problem Solved. The issue was with my wrap width. The line was too long for when a creature put up a shield and that prevented the trigger from picking it up. It is now working. Thank you to everyone who helped me. 
Sign In or Register to comment.