ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/pod/extensions.pod
(Generate patch)

Comparing deliantra/server/pod/extensions.pod (file contents):
Revision 1.1 by elmex, Fri Sep 8 15:34:56 2006 UTC vs.
Revision 1.4 by root, Thu Jan 8 03:03:24 2009 UTC

1=head1 CROSSFIRE+ EXTENSION INTRODUCTION 1=head1 DELIANTRA EXTENSION INTRODUCTION
2 2
3In Crossfire+ the plugin/extension and event API was completly rewritten 3In Deliantra, the plugin/extension and event API was completly rewritten
4in Perl and C++. Here is a small guide or introduction on how to 4in Perl and C++. Here is a small guide or introduction on how to use it.
5use it.
6 5
7If you have any questions don't hesitate to contact the developers, 6If you have any questions don't hesitate to contact the developers,
8see: http://cf.schmorp.de/contact.shtml 7see: http://cf.schmorp.de/contact.shtml
9 8
10 9
11=head2 Extension to <thing> attachments 10=head2 Extension to <thing> attachments
12 11
13You can "attach" extensions to global events, to type/subtypes, 12You can "attach" extensions to global events, to type/subtypes,
14to specifix objects, to players and to maps. 13to specifix objects, to players and to maps.
15 On top of that a extension can implement new user commands. 14On top of that an extension can implement new user commands.
16 15
17If a extension for example wants to attach itself to all jeweler 16If an extension for example wants to attach itself to all jeweler
18skills it has to attach itself like this: 17skills it has to attach itself like this:
19 18
20 cf::attach_to_type cf::SKILL, cf::SK_JEWELER, 19 cf::attach_to_type cf::SKILL, cf::SK_JEWELER,
21 on_use_skill => sub { 20 on_use_skill => sub {
22 ... handling code here ... 21 ... handling code here ...
29can specify a priority with 'prio => -100' to be executed earlier. 28can specify a priority with 'prio => -100' to be executed earlier.
30 29
31You can also attach a Perl package to the skill like this: 30You can also attach a Perl package to the skill like this:
32 31
33 cf::attach_to_type cf::SKILL, cf::SK_JEWELER, 32 cf::attach_to_type cf::SKILL, cf::SK_JEWELER,
34 package => 'Crossfire::JewelerSkill'; 33 package => 'ext::JewelerSkill';
35 34
36cf::attach_to_objects will attach handlers for events on _all_ objects 35cf::attach_to_objects will attach handlers for events on _all_ objects
37in the game, this is mainly for debugging purposes, as it will produce a 36in the game, this is mainly for debugging purposes, as it will produce a
38high load. 37high load.
39 38
40The map attachments work like this: 39The map attachments work like this:
41 40
42If a extension wants to attach itself to the 'trigger' event (this is 41If an extension wants to attach itself to the 'trigger' event (this is
43the event that is generated when a connection is activated (pushed or 42the event that is generated when a connection is activated (pushed or
44released)), it has to do this: 43released)), it has to do this:
45 44
46 cf::attach_to_maps 45 cf::attach_to_maps
47 on_trigger => sub { 46 on_trigger => sub {
48 my ($map, $connection, $state) = @_; 47 my ($map, $connection, $state) = @_;
49 48
50 print "CONNECITON TRIGGERED: $connection : $state\n"; 49 print "CONNECITON TRIGGERED: $connection : $state\n";
51 50
52 for ($map->get_connection ($connection)) { 51 for ($map->find_link ($connection)) {
53 print "connected obj: " . $_->name . "\n"; 52 print "connected obj: " . $_->name . "\n";
54 } 53 }
55 }; 54 };
56 55
57This small attachment dumps all connection activations and the connected 56This small attachment dumps all connection activations and the connected
114This way multiple different attachments have a seperate field for storing 113This way multiple different attachments have a seperate field for storing
115their arguments. 114their arguments.
116 115
117=head2 Defining new user commands 116=head2 Defining new user commands
118 117
119If a extension wants to redefine a user command it does it like this: 118If an extension wants to redefine a user command it does it like this:
120 119
121 cf::register_command invite => 10, sub { 120 cf::register_command invite => 10, sub {
122 my ($who, $args) = @_; 121 my ($who, $args) = @_;
123 ... 122 ...
124 } 123 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines