ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf/mapscript.pm
(Generate patch)

Comparing deliantra/server/lib/cf/mapscript.pm (file contents):
Revision 1.7 by root, Tue Nov 3 23:44:21 2009 UTC vs.
Revision 1.9 by root, Fri Apr 30 18:28:16 2010 UTC

40 40
41=over 4 41=over 4
42 42
43=cut 43=cut
44 44
45package safe::mapscript; 45package cf::mapscript::eval;
46 46
47use common::sense; 47use common::sense;
48 48
49=item $self 49=item $self
50 50
64The object that triggered the activator, usually (but not always) the 64The object that triggered the activator, usually (but not always) the
65player who stepped on a check inv, pulled a lever etc. Can be C<undef>. 65player who stepped on a check inv, pulled a lever etc. Can be C<undef>.
66 66
67=cut 67=cut
68 68
69our ($self, $state, $activator, $originator); 69use vars qw($self $state $activator $originator);
70 70
71=item @obs = find $id_or_object 71=item @obs = find $id_or_object
72 72
73Finds all objects with the given I<connected> C<$id>. If an object 73Finds all objects with the given I<connected> C<$id>. If an object
74reference is passed, it will be returned unchanged. 74reference is passed, it will be returned unchanged.
81} 81}
82 82
83=item trigger $id_or_object[, $state] 83=item trigger $id_or_object[, $state]
84 84
85Triggers the linked chain with the given I<connected> id, or the connected 85Triggers the linked chain with the given I<connected> id, or the connected
86chain associated with the given object (if an objetc reference is passed), 86chain associated with the given object (if an object reference is passed),
87and passes the given state (or C<1>, if missing) to it. 87and passes the given state (or C<1>, if missing) to it.
88 88
89=cut 89=cut
90 90
91sub trigger($;$) { 91sub trigger($;$) {
92 $self->map->trigger ($_[0], $#_ ? $_[1] : 1, $self); 92 $self->map->trigger ($_[0], $#_ ? $_[1] : 1, $self);
93} 93}
94 94
95=item timer $id_or_object, $seconds 95=item timer $id_or_object, $seconds
96 96
97Starts the timer on the given mapscript object (usually, $id_or_object is 97Starts the timer on the given mapscript object (usually, C<$id_or_object> is
98C<$self>). When the timer expires on the mapscript object, it will trigger 98C<$self>). When the timer expires on the mapscript object, it will trigger
99the script with C<$activator == $self> and C<$originator == undef>. 99the script with C<$activator == $self> and C<$originator == undef>.
100 100
101=cut 101=cut
102 102
106 $ob->set_speed (1); 106 $ob->set_speed (1);
107} 107}
108 108
109package cf::mapscript; 109package cf::mapscript;
110 110
111use strict qw(subs vars); 111use common::sense;
112
113*{"main::safe::cf::mapscript::eval::"} = \%{"main::cf::mapscript::eval::"};
112 114
113our %CACHE; 115our %CACHE;
114 116
115sub activate($$$) { 117sub activate($$$) {
118 package cf::mapscript::eval;
119
116 ($self, $state, $activator, $originator) = @_; 120 ($self, $state, $activator, $originator) = @_;
117 121
118 ( 122 (
119 $CACHE{$self->msg} ||= cf::safe_eval 123 $CACHE{$self->msg} ||= cf::safe_eval
120 "package mapscript; sub {\n" 124 "package cf::mapscript::eval; sub {\n"
121 . "#line 1 '" . ($self->debug_desc) . "'\n" 125 . "#line 1 '" . ($self->debug_desc) . "'\n"
122 . $self->msg 126 . $self->msg
123 . "\n}" 127 . "\n}"
124 or sub { } 128 or sub { }
125 )->(); 129 )->();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines