… | |
… | |
27 | }); |
27 | }); |
28 | |
28 | |
29 | sub dialog_tell { |
29 | sub dialog_tell { |
30 | my ($token, $dialog, $msg) = @_; |
30 | my ($token, $dialog, $msg) = @_; |
31 | |
31 | |
|
|
32 | utf8::decode $msg; |
32 | my $pl = $dialog->{ob}->contr; |
33 | my $pl = $dialog->{ob}->contr; |
33 | my ($reply, @kw) = $dialog->tell ($msg); |
34 | my ($reply, @kw) = $dialog->tell ($msg); |
34 | $reply = "..." unless $reply; |
35 | $reply = "..." unless $reply; |
|
|
36 | utf8::encode $_ for ($reply, @kw); |
35 | $pl->send ("ext $token msg " . join "\x00", $reply, @kw); |
37 | $pl->send ("ext $token msg " . join "\x00", $reply, @kw); |
36 | } |
38 | } |
37 | |
39 | |
38 | # return "interesting" information about the given tile |
40 | # return "interesting" information about the given tile |
39 | # currently only returns the npc_dialog title when a dialog is possible |
41 | # currently only returns the npc_dialog title when a dialog is possible |
… | |
… | |
96 | delete $dialog{$_} for grep $pl->ob == $dialog{$_}{ob}, keys %dialog; |
98 | delete $dialog{$_} for grep $pl->ob == $dialog{$_}{ob}, keys %dialog; |
97 | |
99 | |
98 | 0 |
100 | 0 |
99 | } |
101 | } |
100 | |
102 | |
|
|
103 | sub on_unload { |
|
|
104 | while (my ($token, $dialog) = each %dialog) { |
|
|
105 | $dialog->{ob}->contr->send ("ext $token perl_reload"); |
|
|
106 | } |
101 | |
107 | |
|
|
108 | %dialog = (); |
|
|
109 | |
|
|
110 | 0 |
|
|
111 | } |
|
|
112 | |
|
|
113 | |