this plugin will reduce the length of quest conditions where multiple qglobals are checked in a single statement.
Code:
# checks that quest globals are defined and set to values passed in parameters
# usage: my $flagged = plugin::IsFlagged(key=>val, ...);
sub IsFlagged
{
my %flag = @_;
return 0 unless %qglobals;
while (my ($key, $val) = each %flag) {
return 0 unless defined $qglobals{$key} and $qglobals{$key} == $val;
}
1;
}
this, for example:
Code:
if (defined $qglobals{bic} && $qglobals{bic} == 10
&& defined $qglobals{bic_fer} && $qglobals{bic_fer} == 11
&& defined $qglobals{bic_riw} && $qglobals{bic_riw} == 10
&& defined $qglobals{bic_bar} && $qglobals{bic_bar} == 6
&& defined $qglobals{bic_qin} && $qglobals{bic_qin} == 4) {
# do whatever here
}
becomes this:
Code:
my $flagged = plugin::IsFlagged(bic=>10, bic_fer=>11, bic_riw=>10, bic_bar=>6, bic_qin=>4);
if ($flagged) {
# do whatever here
}
or this:
Code:
if (plugin::IsFlagged(bic=>10, bic_fer=>11, bic_riw=>10, bic_bar=>6, bic_qin=>4)) {
# do whatever here
}