--- deliantra/server/ext/NPC_Dialogue.pm 2009/10/13 00:24:14 1.15 +++ deliantra/server/ext/NPC_Dialogue.pm 2009/11/04 19:20:49 1.18 @@ -98,7 +98,7 @@ can be seen by all NPCs (so better name your flags uniquely). This is useful for storing e.g. quest information. See C<@setflag> and C<@ifflag>. -=item @find - see @find, below. +=item $find - see @find, below. =back @@ -158,14 +158,15 @@ =item @find match expression Like C<@check> in that it executes a match expression, but instead of -failing, it gathers all objects matched into the C<@find> array variable. +failing, it gathers all objects into an array and provides a reference to +the array in the C<$find> variable. When you want to skip the match when no objects have been found, combine C<@find> with C<@cond>: @match see my spellbook @find type=SPELLBOOK in inv - @cond @find + @cond @$find It looks dirty. @match see my spellbook I can't see any, where do you have it? @@ -201,13 +202,21 @@ markers and other information (e.g. reputation/alignment). Flags are persistent over the lifetime of a player, so be careful :) +Perversely enough, using C<@setfflag> without a C clears the flag +as if it was never set, so always provide a flag value (e.g. C<1>) when +you want to set the flag. + See C<@ifflag> for an example. =item @ifflag flag value Requires that the named C has the given C, otherwise this -topic is skipped. For more complex comparisons, see C<@cond> with -C<$flag>. Example: +topic is skipped. For more complex comparisons, see C<@cond> with +C<$flag>. + +If no C is given, then the ifflag succeeds when the flag is true. + +Example: @match I want to do the quest! @setflag kings_quest 1 @@ -285,6 +294,7 @@ flag => $flag, msg => $msg, match => \@match, + find => \@find, ); local $self->{ob}{record_replies} = \@replies; @@ -343,7 +353,8 @@ } elsif ($cmd eq "ifflag") { my ($name, $value) = split /\s+/, $args, 2; - $flag->{$name} eq $value + defined $value ? $flag->{$name} eq $value + : $flag->{$name} or next topic; } elsif ($cmd eq "ifstate") {