Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2015, 08:23 PM
chasem
Fire Beetle
 
Join Date: Apr 2014
Posts: 23
Default A better way to write this??

I'm new to PERL and writing quests. Learned a ton just through everyones helpful posts here.

I'm wondering if there is a simpler way to write the following. It is for an NPC that will just be dealing with melee classes. It works, just guessing there is probably an easier way...

Code:
if($class eq 'Druid') { plugin::Whisper("Begone! I will not help a $class!"); return; } #No Druids return...
	if($class eq 'Magician') { plugin::Whisper("Begone! I will not help a $class!"); return; } #No Mages return...
	if($class eq 'Wizard') { plugin::Whisper("Begone! I will not help a $class!"); return; } #No Wizards return...
	if($class eq 'Necromancer') { plugin::Whisper("Begone! I will not help a $class!"); return; } #No Necros return...
	if($class eq 'Shaman') { plugin::Whisper("Begone! I will not help a $class!"); return; } #No Shaman return...
	if($class eq 'Cleric') { plugin::Whisper("Begone! I will not help a $class!"); return; } #No Cleric return...
	if($class eq 'Enchanter') { plugin::Whisper("Begone! I will not help a $class!"); return; } #No Enchanter return...
Thanks for any tips you can give.
Reply With Quote
  #2  
Old 08-27-2015, 08:31 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,595
Default

Try this:
Code:
if($class=~/Druid|Magician|Wizard|Necromancer|Shaman|Cleric|Enchanter/i) {
    plugin::Whisper("Begone! I will not help a $class!");
    return;
}
Reply With Quote
  #3  
Old 08-27-2015, 08:38 PM
chasem
Fire Beetle
 
Join Date: Apr 2014
Posts: 23
Default

Awesome!! Thanks Kingly. Haven't come across the vertical bars used before.
Reply With Quote
  #4  
Old 08-27-2015, 08:48 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

The world is upside-down when a regular expression is actually the simplest way to do something. Hahaha!
Reply With Quote
  #5  
Old 08-27-2015, 08:49 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,595
Default

The | is just an OR operator within REGEX.
Reply With Quote
Reply


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 01:02 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3