ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/eval.ext
Revision: 1.3
Committed: Fri Mar 31 22:18:39 2006 UTC (18 years, 1 month ago) by elmex
Branch: MAIN
Changes since 1.2: +2 -2 lines
Log Message:
added peaceful command change in valriel and gorokh and updated marketplace

File Contents

# Content
1 #! perl
2
3 # generic perl code evaluator
4
5 sub eval_event {
6 my ($event, $args, @args) = @_;
7
8 my $code = $event->message;
9 my $who = eval { $event->environment->name } || "<unknown>";
10
11 my $rv = eval "my ($args) = \@args;\n"
12 . "#line 1 \"$who\"\n"
13 . $code;
14
15 warn $@ if $@;
16
17 $rv
18 }
19
20 # currently say only
21 sub on_say {
22 my ($event) = @_;
23 my ($event, $ob, $who, $msg, $options) = @$event{qw(event who activator message options)};
24
25 local $_ = $msg;
26
27 eval_event $event, '$ob, $who, $msg, $options', $ob, $who, $msg, $options
28 }