This post really did a number on my phone (ever since width was changed on the site). Anyway.
Your formatting is tricking you I believe. All those elsif's belong to the original if.
That said.
Let's assume that:
Code:
$text = "Your format looks a little off"
and if we were to say:
Code:
if ($text =~ /look/i) {
quest::say ("Yep! I found look!");
}
The =~ is a equals match operator, thus the opposite is !~ or does NOT match operator.
/look/ is the pattern (NOT string) that it's looking for. So even though our text variable was "looks" the pattern "look" is still there. The lowercase i after the match operator tells us to "i"gnore case.
Interesting test for you:
Assuming $text equals potions.
Code:
sub EVENT_SAY {
if ($text =~ /potion/i) {
quest::say ("I found potion!");
}
elsif ($text =~ /potions/i) {
quest::say ("I found potions!");
}
}
Now test:
Code:
sub EVENT_SAY {
if ($text =~ /\potion\b/i) {
quest::say ("I found potion!");
}
elsif ($text =~ /\potions\b/i) {
quest::say ("I found potions!");
}
}
Read up on Perl RegEx (Regular Expressions). There is also index, but, stick with regex.
I had a hell of time knowing where I was in my post above. And I dont suspect reviewing it will be any easier. I'm sure someone will come along and correct me if I'm off somewhere, I hope they do anyway.