ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf/mapscript.pm
Revision: 1.3
Committed: Thu Jan 8 19:23:44 2009 UTC (15 years, 5 months ago) by root
Branch: MAIN
Changes since 1.2: +4 -4 lines
Log Message:
mapscript changes

File Contents

# User Rev Content
1 root 1.1 #! perl
2    
3     # this implements the mapscript connectable
4    
5     package safe::mapscript;
6    
7     use strict qw(subs vars);
8    
9 root 1.2 our ($self, $state, $activator, $originator);
10    
11     sub find($) {
12     ref $_[0] ? $_[0]
13     : $self->map->find_link ($_[0])
14     }
15    
16     sub get($) {
17     (&find)[0]->value
18     }
19    
20 root 1.3 sub trigger($;$) {
21 root 1.2 $self->map->trigger ($_[0], $#_ ? $_[1] : 1, $self);
22     }
23    
24     sub timer($$) {
25     my $ob = (&find)[0];
26     $ob->speed_left ($_[1] / -cf::TICK);
27     $ob->set_speed (1);
28     }
29 root 1.1
30     package cf::mapscript;
31    
32     use strict qw(subs vars);
33    
34 root 1.3 our %CACHE;
35    
36 root 1.1 sub activate($$$) {
37 root 1.2 ($self, $state, $activator, $originator) = @_;
38 root 1.1
39     (
40 root 1.3 $CACHE{$self->msg} ||= cf::safe_eval
41 root 1.1 "package mapscript; sub {\n"
42     . "#line 1 '" . ($self->debug_desc) . "'\n"
43     . $self->msg
44     . "\n}"
45     or sub { }
46     )->();
47     }
48    
49     1;