Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Custom

Quests::Custom Custom Quests here

Reply
 
Thread Tools Display Modes
  #1  
Old 02-11-2017, 12:07 AM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

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.
Reply With Quote
  #2  
Old 02-11-2017, 01:08 PM
Dharrk
Fire Beetle
 
Join Date: Aug 2009
Location: Czech Republic
Posts: 6
Default

Thank you for the response Ghanja. I was told elsif would help to prevent memory leaks which is why I use them constantly; I have been scripting for may be 2 months. I will look into the perl regular expressions and see if I cannot clean the script up somewhat.
Reply With Quote
  #3  
Old 02-11-2017, 11:33 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Quote:
Originally Posted by Dharrk View Post
Thank you for the response Ghanja. I was told elsif would help to prevent memory leaks which is why I use them constantly; I have been scripting for may be 2 months. I will look into the perl regular expressions and see if I cannot clean the script up somewhat.
It was nothing against your efforts, rather, the expanding or widening of the site forums itself (something Akka did a year or so ago). I really must ask what browser he uses, so that I no longer have to scroll horizontally.

"if" is a conditional, and as such will be checked each time

"elsif" is also a conditional that if the originating if was not true, will be checked/considered, stopping upon the first met condition of that if/elsif nesting.

The use of them is a bit much, yes, though the problem was in your regex, not the large number of elsif's. Krab has provided a hash / iteration method, also using length, substr, new regex operator, etc. Plenty to digest, but, beneficial as you'll hopefully learn from it.
Reply With Quote
  #4  
Old 02-11-2017, 11:44 PM
GRUMPY
Discordant
 
Join Date: Oct 2016
Posts: 445
Default

Quote:
Originally Posted by ghanja View Post
I really must ask what browser he uses, so that I no longer have to scroll horizontally.
I use "view" > zoom out :P
Reply With Quote
  #5  
Old 02-12-2017, 10:23 AM
Dharrk
Fire Beetle
 
Join Date: Aug 2009
Location: Czech Republic
Posts: 6
Default

That works beautifully Kingly thank you for the rework. Thank you Ghanja for pointing me to regular expressions. I had meant not ill will towards you by saying I had only been scripting 2 months just letting you know the extent of my ability. With your mention of expressions and Kinglys example I do have a lot to digest. Thank you both.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 09:58 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3