This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
plugin_python [2007/03/22 04:55] 127.0.0.1 external edit |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== CFPython version 1.0 ====== | ||
- | **This documentation is about the old plugin system. It is obsolete and should not be used, except for historical purposes. | ||
- | |||
- | Documentation for current Python plugin can be found [[cfpython|here]].** | ||
- | |||
- | ==== How do I hook a script to an object? ==== | ||
- | |||
- | Use the **''event_xxx''** to specify the script to use. The base directory for the scripts is the **''map''** directory. | ||
- | |||
- | * The option field is unused for now. | ||
- | * The plugin field should be "Python" of course. | ||
- | |||
- | You of course need to write some Python code too... You do as usual, but remember to add an "**''import [[CFPython]]''**" to make all crossfire-specific functions available in your scripts. | ||
- | |||
- | ==== How do I hook a global event? ==== | ||
- | |||
- | Each global event is bound to a specific Python script file. Those files are located in the ''python/'' subdirectory of your crossfire map directory. They have specific names, too: **''python_xxx.py''**, where **''xxx''** is the name of the global event you want to intercept. For example, a script that should be run each time a player logs in (**''"login" event''**) should be named **''python_login.py''**. | ||
- | |||
- | ==== What are the events? ==== | ||
- | |||
- | Here is a listing of the **server events** and their number codes: | ||
- | |||
- | <code> | ||
- | EVENT_NONE 0 No event. This exists only to reserve the "0". | ||
- | EVENT_APPLY 1 Object applied-unapplied. | ||
- | EVENT_ATTACK 2 Monster attacked or Scripted Weapon used. | ||
- | EVENT_DEATH 3 Player or monster dead. | ||
- | EVENT_DROP 4 Object dropped on the floor. | ||
- | EVENT_PICKUP 5 Object picked up. | ||
- | EVENT_SAY 6 Someone speaks. | ||
- | EVENT_STOP 7 Thrown object stopped. | ||
- | EVENT_TIME 8 Triggered each time the object can react/move. | ||
- | EVENT_THROW 9 Object is thrown. | ||
- | EVENT_TRIGGER 10 Button pushed, lever pulled, etc. | ||
- | EVENT_CLOSE 11 Container closed. | ||
- | EVENT_TIMER 12 Timer connected triggered it. | ||
- | </code> | ||
- | |||
- | And the **global events** are: | ||
- | |||
- | <code> | ||
- | EVENT_BORN 13 A new character has been created. | ||
- | EVENT_CLOCK 14 Global time event. | ||
- | EVENT_CRASH 15 Triggered when the server crashes. Not recursive | ||
- | EVENT_GDEATH 16 Global Death event | ||
- | EVENT_GKILL 17 Triggered when anything got killed by anyone. | ||
- | EVENT_LOGIN 18 Player login. | ||
- | EVENT_LOGOUT 19 Player logout. | ||
- | EVENT_MAPENTER 20 A player entered a map. | ||
- | EVENT_MAPLEAVE 21 A player left a map. | ||
- | EVENT_MAPRESET 22 A map is resetting. | ||
- | EVENT_REMOVE 23 A Player character has been removed. | ||
- | EVENT_SHOUT 24 A player 'shout' something. | ||
- | </code> | ||
- | |||
- | ==== What functions are currently supported? ==== | ||
- | |||
- | //A complete list of supported functions is given below.// | ||
- | |||
- | //__Note to Scriptfire users__: [[CFPython]] implements all the old Scriptfire functions. Although the syntax of Python is quite different from Guile, it should not be a problem to port your old code.// | ||
- | |||
- | Last count (10/09/2001) result: 181 functions (not counting the various spells and skills wrappers). This of course does not include all the Python functions, just the crossfire-specific ones. | ||
- | |||
- | In the following, I use the following type naming convention: | ||
- | |||
- | * **''int''** : An integer; | ||
- | * **''long''** : A long; | ||
- | * **''object''**: A crossfire object. (In fact, it is a long). | ||
- | * **''string''**: A character string. | ||
- | |||
- | //Chachkoff Y.// |