ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/NPC_Dialogue.pm
(Generate patch)

Comparing deliantra/server/ext/NPC_Dialogue.pm (file contents):
Revision 1.4 by root, Sat Jun 16 14:35:41 2007 UTC vs.
Revision 1.7 by elmex, Sat Aug 25 16:51:38 2007 UTC

3NPC_Dialogue 3NPC_Dialogue
4 4
5=head1 DESCRIPTION 5=head1 DESCRIPTION
6 6
7NPC dialogue support module. 7NPC dialogue support module.
8
9=over 4
8 10
9=cut 11=cut
10 12
11package NPC_Dialogue; 13package NPC_Dialogue;
12 14
104 106
105=back 107=back
106 108
107The environment is that standard "map scripting environment", which is 109The environment is that standard "map scripting environment", which is
108limited in the type of constructs allowed (no loops, for example). 110limited in the type of constructs allowed (no loops, for example).
111
112Here is a example:
113
114=over 4
115
116=item B<matching for an item name>
117
118 @match hi
119 @cond grep $_->name =~ /royalty/, $who->inv
120 You got royalties there! Wanna have!
121
122You may want to change the C<name> method there to something like C<title>,
123C<slaying> or any other method that is allowed to be called on a
124C<cf::object> here.
125
126=item B<matching for an item name and removing the matched item>
127
128 @match found earhorn
129 @cond grep $_->slaying =~ /Gramp's walking stick/, $who->inv
130 @eval my @g = grep { $_->slaying =~ /Gramp's walking stick/ } $who->inv; $g[0]->decrease_ob_nr (1);
131 Thanks for the earhorn!
132
133This example is a bit more complex. The C<@eval> statement will search
134the players inventory for the same term as the C<@cond> and then
135decreases the number of objects used there.
136
137(See also the map: C<scorn/houses/cornerbrook.map> for an example how this is
138used in the real world :-)
139
140=back
109 141
110=item @eval perl 142=item @eval perl
111 143
112Like C<@cond>, but proceed regardless of the outcome. 144Like C<@cond>, but proceed regardless of the outcome.
113 145

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines