1 | =head1 CROSSFIRE+ EXTENSION INTRODUCTION |
1 | =head1 DELIANTRA EXTENSION INTRODUCTION |
2 | |
2 | |
3 | In Crossfire+ the plugin/extension and event API was completly rewritten |
3 | In Deliantra, the plugin/extension and event API was completly rewritten |
4 | in Perl and C++. Here is a small guide or introduction on how to |
4 | in Perl and C++. Here is a small guide or introduction on how to use it. |
5 | use it. |
|
|
6 | |
5 | |
7 | If you have any questions don't hesitate to contact the developers, |
6 | If you have any questions don't hesitate to contact the developers, |
8 | see: http://cf.schmorp.de/contact.shtml |
7 | see: http://cf.schmorp.de/contact.shtml |
9 | |
8 | |
10 | |
9 | |
11 | =head2 Extension to <thing> attachments |
10 | =head2 Extension to <thing> attachments |
12 | |
11 | |
13 | You can "attach" extensions to global events, to type/subtypes, |
12 | You can "attach" extensions to global events, to type/subtypes, |
14 | to specifix objects, to players and to maps. |
13 | to specifix objects, to players and to maps. |
15 | On top of that a extension can implement new user commands. |
14 | On top of that an extension can implement new user commands. |
16 | |
15 | |
17 | If a extension for example wants to attach itself to all jeweler |
16 | If an extension for example wants to attach itself to all jeweler |
18 | skills it has to attach itself like this: |
17 | skills 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 ... |
… | |
… | |
29 | can specify a priority with 'prio => -100' to be executed earlier. |
28 | can specify a priority with 'prio => -100' to be executed earlier. |
30 | |
29 | |
31 | You can also attach a Perl package to the skill like this: |
30 | You 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 | |
36 | cf::attach_to_objects will attach handlers for events on _all_ objects |
35 | cf::attach_to_objects will attach handlers for events on _all_ objects |
37 | in the game, this is mainly for debugging purposes, as it will produce a |
36 | in the game, this is mainly for debugging purposes, as it will produce a |
38 | high load. |
37 | high load. |
39 | |
38 | |
40 | The map attachments work like this: |
39 | The map attachments work like this: |
41 | |
40 | |
42 | If a extension wants to attach itself to the 'trigger' event (this is |
41 | If an extension wants to attach itself to the 'trigger' event (this is |
43 | the event that is generated when a connection is activated (pushed or |
42 | the event that is generated when a connection is activated (pushed or |
44 | released)), it has to do this: |
43 | released)), 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 { |
… | |
… | |
114 | This way multiple different attachments have a seperate field for storing |
113 | This way multiple different attachments have a seperate field for storing |
115 | their arguments. |
114 | their arguments. |
116 | |
115 | |
117 | =head2 Defining new user commands |
116 | =head2 Defining new user commands |
118 | |
117 | |
119 | If a extension wants to redefine a user command it does it like this: |
118 | If 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 | } |