… | |
… | |
3 | NPC_Dialogue |
3 | NPC_Dialogue |
4 | |
4 | |
5 | =head1 DESCRIPTION |
5 | =head1 DESCRIPTION |
6 | |
6 | |
7 | NPC dialogue support module. |
7 | NPC dialogue support module. |
|
|
8 | |
|
|
9 | =over 4 |
8 | |
10 | |
9 | =cut |
11 | =cut |
10 | |
12 | |
11 | package NPC_Dialogue; |
13 | package NPC_Dialogue; |
12 | |
14 | |
… | |
… | |
26 | } |
28 | } |
27 | |
29 | |
28 | sub new { |
30 | sub new { |
29 | my ($class, %arg) = @_; |
31 | my ($class, %arg) = @_; |
30 | |
32 | |
|
|
33 | $arg{ob} = $arg{pl}->ob; |
|
|
34 | |
31 | my $self = bless { |
35 | my $self = bless { |
32 | %arg, |
36 | %arg, |
33 | }, $class; |
37 | }, $class; |
34 | |
38 | |
35 | $self->{match} ||= [parse_message $self->{npc}->msg]; |
39 | $self->{match} ||= [parse_message $self->{npc}->msg]; |
… | |
… | |
102 | |
106 | |
103 | =back |
107 | =back |
104 | |
108 | |
105 | The environment is that standard "map scripting environment", which is |
109 | The environment is that standard "map scripting environment", which is |
106 | limited in the type of constructs allowed (no loops, for example). |
110 | limited in the type of constructs allowed (no loops, for example). |
|
|
111 | |
|
|
112 | Here 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 | |
|
|
122 | You may want to change the C<name> method there to something like C<title>, |
|
|
123 | C<slaying> or any other method that is allowed to be called on a |
|
|
124 | C<cf::object> here. |
|
|
125 | |
|
|
126 | =back |
107 | |
127 | |
108 | =item @eval perl |
128 | =item @eval perl |
109 | |
129 | |
110 | Like C<@cond>, but proceed regardless of the outcome. |
130 | Like C<@cond>, but proceed regardless of the outcome. |
111 | |
131 | |