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 09-02-2007, 12:44 PM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

Quote:
Originally Posted by sonicintuition View Post

So ....I'll hail the NPC with a rogue, and get "You are not a caster! You are a caster!" ....

Code:
sub EVENT_SAY
{
if($text=~/hail/i && ($class eq 'Warrior' || $class eq 'Rogue'))
{
quest::say("You are not a caster!");
}
if($text=~/hail/i && ($class ne 'Warrior' || $class ne 'Rogue'))
{
quest::say("You are a caster!");
}
}
Sonic
broken logic. on the "second" if, if i'im a rogue, it will fire because, you're asking a different question:

if $text contains "hail"

and

the $class is either ( not warrior ) or (not rogue)

which is true if you're a rogue ( rogue != warrior ).

converse statements (ones containing "negations" ) are usually tricky and require some care. you're easiest bet would be to construct it like follows:

if( contains "hail" )
{
if( class1 ) { do something }
elsif (class2 ) { do something else }
elsif( class3 ) { do something else }
...
else { do the other thing }
}


hope this helps.

== sfisque
Reply With Quote
  #2  
Old 09-02-2007, 01:24 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

sfisque;
Are "if" and "elsif" any different? will Perl look at all the "ifs" or all the "elsifs"? or will it always stop at the first "if" or "elsif" once the it finds a match?
Reply With Quote
  #3  
Old 09-02-2007, 01:34 PM
WildcardX
Developer
 
Join Date: Apr 2003
Posts: 589
Default

in a if...elsif..else construct, only ONE of the specificied conditions can be true.. so it will evaluate the IF first and then if that IF isn't TRUE, perl moves on to the first ELSIF.. if that is also not true then every elseif next is evaluated one at a time and in order until either one of the elsif are true OR it finally reaches an ELSE clause, if one is present.. Hope this is readable.. lol
__________________
Read my developer notes at my blog.

Quote:
If it's not on IRC, it ain't l33t!
Reply With Quote
  #4  
Old 09-02-2007, 06:10 PM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

Quote:
Originally Posted by Angelox View Post
sfisque;
Are "if" and "elsif" any different? will Perl look at all the "ifs" or all the "elsifs"? or will it always stop at the first "if" or "elsif" once the it finds a match?
think of if/elsif...else blocks as the perl version of a C switch statement, where each if/elsif is analogous to a case X: and else is the default: subblock.

== sfisque
Reply With Quote
  #5  
Old 09-02-2007, 07:25 PM
sonicintuition
Hill Giant
 
Join Date: Jan 2005
Posts: 124
Default

You people lost me ... Anyway what I did works, I'll try the other one that sfisque posted after that ..see if that works, if it does ...yay, the file will be smaller

Regards,
Sonic
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 12:54 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 - 2026, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3