View Single Post
  #9  
Old 05-26-2008, 01:00 AM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default

No

You need just remember that $qglobals{max_level} is the replacement for $max_level.

So you could use :
Code:
if(defined($qglobals{max_level}))
to check that the variable is defined, in the same way you could have used if(defined($max_level))

Or you could use :
Code:
if($qglobals{max_level}) == 75)
to check if the variable is equal to 75 (after you have ensured it is defined !), in the same way you could have used if($max_level == 75)

If you want the safe solution in one "if" :
Code:
if(defined($qglobals{max_level}) && $qglobals{max_level} == 75)
With cascading "if"s :
Code:
if(!defined($qglobals{max_level}))
{ # Here you assume Max Level is 70 I guess
}
elsif($qglobals{max_level} == 71)
{ # Max Level is 71
}
elsif($qglobals{max_level} == 72)
{ # Max Level is 72
}
elsif($qglobals{max_level} == 73)
{ # Max Level is 73
}
elsif($qglobals{max_level} == 74)
{ # Max Level is 74
}
elsif($qglobals{max_level} == 75)
{ # Max Level is 75
}
else
{ # Damnit ! A super-hero !
}
Finally you can use a temporary variable (for a briefer notation), I just hope you won't get a warning in case the quest global is not defined, Perl's subtleties sometimes evade me :
Code:
$MaxLevel = $qglobals{max_level};
if(defined($MaxLevel) && $MaxLevel  == 75)
Notice how I propose a temporary variable different from max_level, to avoid any new weirdness

Note that to undefine a Perl variable I normally use this, instead of $XXX = undef :
Code:
undef($XXX);
I do not know whether both are equivalent. To delete a quest global from the DB the function to use is quest::delglobal as Gonner mentioned, which probably does NOT "undef" the associated variable. I have no idea whether the $qglobals map is updated at the same time, or only on next call to the script. This will have to be tested. it is the best way to know. In fact this should be tested for both delglobal and setglobal, and I hope they behave in a consistent way.
Reply With Quote