--- deliantra/server/ext/map_lib.ext 2006/12/21 22:41:34 1.3 +++ deliantra/server/ext/map_lib.ext 2008/04/21 06:35:26 1.6 @@ -61,7 +61,7 @@ $match = $ob; }); if ($match) { - $match->decrease_ob_nr ($cfg->{decrease_by_cnt}) if $cfg->{decrease_by_cnt}; + $match->decrease ($cfg->{decrease_by_cnt}) if $cfg->{decrease_by_cnt}; $pl->message ($cfg->{message_on_match}, cf::NDI_UNIQUE) if defined $cfg->{message_on_match}; } else { $pl->message ($cfg->{message_on_nomatch}, cf::NDI_RED | cf::NDI_UNIQUE) if defined $cfg->{message_on_nomatch}; @@ -69,6 +69,87 @@ } }; + +=item object attachment: 'trigger_on_dialog_flag' + +This attachment checks whether the player has a specific +dialog flag set (the ones you can set with @setflag, see also +L, and triggers a connection depending on that. + +The attachment has following configuration: + +=over 4 + +=item flag + +This field should contain the name of the flag that you want to check +for. + +=item connection + +The connection ID of the connection you want to trigger. + +=item state + +The state of the connection: 0 for release, 1 for push. + +=back + +=cut + +cf::object::attachment trigger_on_dialog_flag => + on_move_trigger => sub { + my ($self, $who, $orig) = @_; + my $cfg = $self->{trigger_on_dialog_flag}; + if (exists $who->{ob}{dialog_flag}{$cfg->{flag}}) { + if ($who->{ob}{dialog_flag}{$cfg->{flag}}) { + $self->map->trigger ($cfg->{connection}, $cfg->{state}); + } + cf::override; + } + }; + +=item object attachment: 'display_info_window' + +If you attach this attachment to a sign a window containing the +message will open in the client when the player applies it. + +Use this feature with care, as popups usually are very noisy. +This is mostly thought for tutorial or other instructions. + +=cut + +cf::object::attachment display_info_window => + on_apply => sub { + my ($self, $pl) = @_; + + return unless $pl->contr->ns->{can_widget}; + + my $cfg = $self->{display_info_window}; + + if ($pl->contr->ns->{info_wins}->{$self->uuid}) { + $pl->contr->ns->{info_wins}->{$self->uuid}->destroy; + } + + my $ws = $pl->contr->ns->new_widgetset; + + my $w = $ws->{my_main} = $ws->new (Toplevel => + force_w => 600, + force_h => 400, + x => 'center', + y => 'center', + title => 'Information Sign', + has_close_button => 1, + on_delete => sub { $ws->destroy }, + ); + $w->add ($ws->{txt_area} = $ws->new ('TextScroller')); + $ws->{txt_area}->add_paragraph ($self->msg); + $w->show; + $pl->contr->ns->{info_wins}->{$self->uuid} = $ws; + + cf::override 1; + }; + =back =cut