ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/eval.ext
Revision: 1.4
Committed: Fri Mar 31 22:47:19 2006 UTC (18 years, 1 month ago) by root
Branch: MAIN
Changes since 1.3: +2 -3 lines
Log Message:
api change

File Contents

# User Rev Content
1 root 1.1 #! perl
2    
3     # generic perl code evaluator
4    
5 root 1.2 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 root 1.1 # currently say only
21     sub on_say {
22 root 1.4 my ($event, $ob, $who, $msg) = @_;
23 root 1.1
24     local $_ = $msg;
25 root 1.2
26 root 1.4 eval_event $event, '$ob, $who, $msg', $ob, $who, $msg
27 root 1.1 }