[CF-Devel] Plugins and Python

Yann Chachkoff yann.chachkoff at mailandnews.com
Fri Sep 6 05:07:08 CDT 2002


Well, maybe I should read all the mails on this list more often - Probably 
some questions could have been answered sooner, then. 
Some summarized notes about the plugins in general, and Python in particular:
 
Administrative commands (only available in DM mode): 
---------------------------------------------------- 
pluglist

 Lists all loaded plugins. Each plugin is identified in Crossfire by a 
keyword; pluglist shows those keywords, as well as a short text describing 
each plugin (usually a version string). If no plugin is loaded, the list will 
simply appear empty. The keyword for the Python plugin is Python.
 
plugout <keyword>

 Unloads a given plugin, identified by its _keyword_. So if you want to unload 
the Python plugin, you need to do 'plugout Python'.
 
plugin <libname>

 Loads a given plugin, whose _filename_ is libname. So in the case of Python, 
you'd have to do a 'plugin plugin_python.so.0.1'. Note that all filenames are 
relative to the default plugin path (SHARE/plugins).
 
Console messages. 
----------------- 
When Crossfire starts, it tries to load all available files in the 
SHARE/plugins directory as plugin libraries. It first displays the 
'Initializing plugins:' message. Whenever a plugin has been loaded, the plugin 
has the opportunity to signal itself by a message on the console. Then the 
server displays an informative message containing both the plugin content and 
its keyword. For the Python plugin, the standard load process thus gives:
 
Initializing plugins :
  -> Loading plugin : plugin_python.so.0.1
    Plugin CFPython Plugin 0.1 loaded under the name of Python 
Done
 
When a plugin has been loaded, it can request to be warned whenever a global 
event occurs (global events are 'shout', 'login', 'death', and so on). When a 
plugin makes such a request, a message is displayed in the console log:
 
Plugin Python (0) registered the event 13
 
It simply tells that the plugin associated with the keyword 'Python' asked to 
be warned whenever the global event Nr. 13 ('New player born') occurs. A 
complete list of events is available in the include/plugin.h file.
 
Specific notes related to the Python Plugin. 
-------------------------------------------- 
The Python plugin supports all global events. The constant PYTHON_DEBUG 
defined at the start of the plugin_python.c file increases the verbosity of 
the plugin. Although it should work with Python 1.x, I strongly suggest using 
a 2.x version instead.
 
Global event scripts go into SHARE/maps/python, and are named python_xxx.py, 
where xxx is the name of the global event to intercept. If the file doesn't 
exist, nothing will happen.
 
Some problems have already been reported about the autodetection of the Python 
libraries. Don't forget that you need the development files of Python (it 
means the 'libpython2.x.a' and some header files, including 'Python.h'). If 
configure fails whatever you try, you can still try to edit the plugin 
Makefile by hand. You need to: 
- Add your Python headers path to the INCLUDES= line. (for example: 
-I/usr/include/python2.2); 
- Add your Python library path to the PYTHON_LIB= line. (for example: 
/usr/lib/python2.2/config/libpython2.2.a) 
And then build the plugin after the server. Although I do not recommend this 
technique, it may help sometimes.
 
The plugin compiled under Win32 systems last year (using VC++ 6 compiler), but 
I don't know if it still works. Probably testing it on platforms other than 
Linux would also be a good thing - a lot of time passed since I last worked on 
it.
 
Status of the logger and animator plugins isn't know (I didn't made them). 
Probably I should test those, too.
 
In the hope all this could help someone...

Y. Chachkoff
------------------------------------------------
Help supporting JXFire ! (
     
     http://jxfire.sf.net
     
     )
------------------------------------------------


    
    


More information about the crossfire mailing list