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-11-2009, 08:02 AM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

Quote:
Originally Posted by trevius View Post
A better way to write this might be the following:

Code:
	if($text=~/Hail/i)
 	{
 	 	if($qglobals{rin_quest} == 1)
		{
			$client->Message(5, ("Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
		}
		else
		{
 			quest::emote("jumps at your voice, and begins breathing heavily...");
 			$client->Message(5, "Oh, it's just you. I bet [you think I'm crazy] too, huh? Everyone thinks I'm crazy!");
		}
	}
Just to caveat, you should also check if the global is defined before making a == check.
Code:
if(defined($qglobals{rin_quest}) && $qglobals{rin_quest} == 1)
Reply With Quote
  #2  
Old 09-11-2009, 11:06 AM
Congdar
Developer
 
Join Date: Jul 2007
Location: my own little world
Posts: 751
Default

Quote:
Originally Posted by joligario View Post
Just to caveat, you should also check if the global is defined before making a == check.
Code:
if(defined($qglobals{rin_quest}) && $qglobals{rin_quest} == 1)
Checking if the global is defined first is good practice. Not doing that will get your log files filled up with perl messages about undefined variable use. The script will still work if you don't check, but when an actual error happens and you need to study the log files, it's nice to not have to wade through Perl error messages that aren't related to the error you are looking for.

In this case where all you are doing is setting a flag once, the second part is not needed.
Code:
if(defined($qglobals{rin_quest}))
is the same as
Code:
if(defined($qglobals{rin_quest}) && $qglobals{rin_quest} == 1)
The second part would only be needed if you were to use the global for further questing and updating the qglobal value to 2, 3, etc.


Additionally, organization of the code helps readability for others should the script need to be updated to extend the quest or change it.
Code:
EVENT_SAY {

if(defined($qglobals{rin_quest}) {

    if($text=~/Hail/i) {
        quest::say("This is the flagged conversation section");
    }

}
else {

    if($text=~/Hail/i) {
        quest::say("This is the NON-flagged conversation section");
    }

}
}
then if later you want to extend the quest using the same qglobal
Code:
EVENT_SAY {

if(defined($qglobals{rin_quest}) {

    if($qglobals{rin_quest} == 1) {

        if($text=~/Hail/i) {
            quest::say("This is the flagged==1 conversation section");
        }
    }

    if($qglobals{rin_quest} == 2) {

        if($text=~/Hail/i) {
            quest::say("This is the flagged==2 conversation section");
        }
    }

}
else {

    if($text=~/Hail/i) {
        quest::say("This is the NON-flagged conversation section");
    }

}
}

Last edited by Congdar; 09-11-2009 at 11:20 AM..
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 08:52 PM.


 

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