ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf/mapscript.pm
Revision: 1.2
Committed: Thu Jan 8 04:35:04 2009 UTC (15 years, 5 months ago) by root
Branch: MAIN
Changes since 1.1: +21 -2 lines
Log Message:
add originator

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     sub set($;$) {
21     $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     sub activate($$$) {
35 root 1.2 ($self, $state, $activator, $originator) = @_;
36 root 1.1
37     warn "$self->{msg} $self->{on_activate}\n";#d#
38    
39     (
40     $self->{on_activate} ||= cf::safe_eval
41     "package mapscript; sub {\n"
42     . "#line 1 '" . ($self->debug_desc) . "'\n"
43     . $self->msg
44     . "\n}"
45     or sub { }
46     )->();
47     }
48    
49     1;