question on matches[2]

Post Reply
Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

question on matches[2]

Post by Israafiyl »

So I am trying to figure out how to check matches[2] for certain words. Like if my target is zombie and I see "A nearly invisible magical shield forms around a small zombie." I have a trigger A nearly invisible magical shield forms around (.*). How can I make this check my target and if my target is the same as a word in the wildcard it will match? I am sorry if my question does not make much sense I am a bit tired

Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Re: question on matches[2]

Post by Delrayne »

Well...it depends on how you target....I'm assuming you just use 'zombie' rather than 'a small zombie'.
Code: [show] | [select all] lua
if (string.find(matches[2], targetVariable) then
   send("stuff to do")
else
    return
end
If you use 'a small zombie' then you can just do this.
Code: [show] | [select all] lua
if (matches[2] == targetVariable) then
    send("stuff to do")
end

Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

Re: question on matches[2]

Post by Israafiyl »

Thank you very very much

Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

Re: question on matches[2]

Post by Israafiyl »

I am getting an error that I cant seem to figure out Lua syntax error: )' expected near 'then'

Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Re: question on matches[2]

Post by Delrayne »

oh, add another ')' by targetVariable ....I'm bad about leaving out parenthesis when I use a function inside if statements...part of the drawback of using them when you don't have to, but I like the separation it gives.

Israafiyl
Posts: 56
Joined: Mon Jul 16, 2012 12:29 am

Re: question on matches[2]

Post by Israafiyl »

excellent thanks again

Post Reply