… | |
… | |
164 | |
164 | |
165 | @match hi |
165 | @match hi |
166 | @ifflag kings_quest |
166 | @ifflag kings_quest |
167 | Hi, I was told you want to do the kings quest? |
167 | Hi, I was told you want to do the kings quest? |
168 | |
168 | |
169 | =item @trigger connected-id |
169 | =item @trigger connected-id [state] |
170 | |
170 | |
171 | Trigger all objects with the given connected-id. The trigger is stateful |
171 | Trigger all objects with the given connected-id. |
172 | and retains state per connected-id. |
172 | |
|
|
173 | When the state argument is omitted the trigger is stateful and retains an |
|
|
174 | internal state per connected-id. There is a limitation to the use of this: The |
|
|
175 | state won't be changed when the connection is triggered by other triggers. So |
|
|
176 | be careful when triggering the connection from other objects. |
|
|
177 | |
|
|
178 | When a state argument is given it should be either 0 or 1. 1 will 'push' the connection |
|
|
179 | and 0 will 'release' the connection. This is useful for example when you want to |
|
|
180 | let a npc control a door. |
|
|
181 | |
|
|
182 | Trigger all objects with the given connected-id by 'releasing' the connection. |
173 | |
183 | |
174 | =item @addtopic topic |
184 | =item @addtopic topic |
175 | |
185 | |
176 | Adds the given topic names (separated by C<|>) to the list of topics |
186 | Adds the given topic names (separated by C<|>) to the list of topics |
177 | returned. |
187 | returned. |
… | |
… | |
186 | my $lcmsg = lc $msg; |
196 | my $lcmsg = lc $msg; |
187 | |
197 | |
188 | topic: |
198 | topic: |
189 | for my $match (@{ $self->{match} }) { |
199 | for my $match (@{ $self->{match} }) { |
190 | for (split /\|/, $match->[0]) { |
200 | for (split /\|/, $match->[0]) { |
191 | if ($_ eq "*" || $lcmsg eq lc) { |
201 | if ($_ eq "*" || $lcmsg =~ /\b\Q$_\E\b/i) { |
192 | my $reply = $match->[1]; |
202 | my $reply = $match->[1]; |
193 | my @kw; |
203 | my @kw; |
194 | |
204 | |
195 | my @replies; |
205 | my @replies; |
196 | my @match; # @match/@parse command results |
206 | my @match; # @match/@parse command results |
… | |
… | |
251 | my ($name, $value) = split /\s+/, $args, 2; |
261 | my ($name, $value) = split /\s+/, $args, 2; |
252 | $state->{$name} eq $value |
262 | $state->{$name} eq $value |
253 | or next topic; |
263 | or next topic; |
254 | |
264 | |
255 | } elsif ($cmd eq "trigger") { |
265 | } elsif ($cmd eq "trigger") { |
|
|
266 | my ($con, $state) = split /\s+/, $args, 2; |
|
|
267 | $con = $con * 1; |
|
|
268 | |
|
|
269 | if (defined $state) { |
|
|
270 | $self->{npc}->map->trigger ($args, $state); |
|
|
271 | } else { |
256 | my $rvalue = \$self->{npc}{dialog_trigger}{$args*1}; |
272 | my $rvalue = \$self->{npc}{dialog_trigger}{$con}; |
257 | $self->{npc}->map->trigger ($args, $$rvalue = !$$rvalue); |
273 | $self->{npc}->map->trigger ($con, $$rvalue = !$$rvalue); |
|
|
274 | } |
258 | |
275 | |
259 | } elsif ($cmd eq "addtopic") { |
276 | } elsif ($cmd eq "addtopic") { |
260 | push @kw, split /\|/, $args; |
277 | push @kw, split /\|/, $args; |
261 | $self->{add_topic}->(split /\s*\|\s*/, $args) if $self->{add_topic}; |
278 | $self->{add_topic}->(split /\s*\|\s*/, $args) if $self->{add_topic}; |
262 | |
279 | |