[Crossfire-wiki] [Crossfire DokuWiki] page changed: cfpython

www-data at wiki.metalforge.net www-data at wiki.metalforge.net
Wed Nov 15 11:21:36 CST 2006


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2006/11/15 11:21
User        : ryo
Edit Summary: + scripts in python subdir, some info

@@ -5,18 +5,21 @@
  Old plugin's reference can be found on [[plugin_python]].
  
  ====== General information ======
  
- The plugin has access to all built-in functions of Python, and its regular libraries.
+ The plugin has access to all built-in functions of Python, and its regular libraries. Python version being used depends on the platform the server was built, but should be 2.3 or higher. FIXME {is that always true?}
  
  Using a library not part of Python's default distribution is discouraged as this introduces new dependencies.
  
  Scripts execute in their own context, and their state information is not kept between runs. There are functions to persist data, or share between scripts. Note that persisted data will not survive a server restart.
- 
  
  Scripts should import the ''Crossfire'' module to access Crossfire's built-in functions.
  
  Calling Crossfire functions with invalid arguments will result in a Python exception being raised. A function failure will also result in an exception.
+ 
+ Scripts will have the same access rights as the server itself. It may be able to write to some directories, but not others.
+ 
+ Data should be persisted in the ''PlayerDirectory'' (for specific player information) or ''DataDirectory'' (for reglar information), where server normally has write access.
  
  ===== How do I hook a script to an object? =====
  
  Python plugin is a [[server plugin]], thus you need to insert in this object one of the //event_xxx// archetype (see ''arch/system'' directory). The fields to fill are:
@@ -66,8 +69,14 @@
  The return value of the script can manipulated through the ''GetReturnValue'' and ''SetReturnValue'' functions. Signification of this value depends on the event being handled.
  
  
  ====== Python API reference ======
+ 
+ The following functions and objects are available to all scripts using the Crossfire module through ''import Crossfire''.
+ 
+ **Convention:** in the reference, ''xxx()'' specifies a method, ''xxx'' specifies a property.
+ 
+ ===== Constants =====
  
  Constants are available to wrap values used in Crossfire code like object types, movements, ...
  They are available through ''Crossfire.xxx.VALUE'', where ''xxx'' is the constant type and ''VALUE'' the value as in the C sources code in uppercase.
  
@@ -81,11 +90,8 @@
  Example:
  ''whoami.Say("%s => %d"%(Crossfire.DirectionName[Crossfire.Direction.NORTH],Crossfire.Direction.NORTH))'' will write ''NORTH => 1''
  
  **Warning**: Python doesn't know about constants, thus scripts can modify those values. Doing this can lead to weird results, and should be avoided at all cost. Note that the C code itself is immune to the changes, only the scripts would suffer.
- 
- **Note:** in the reference, ''xxx()'' specifies a method, ''xxx'' specifies a property.
- 
  
  
  ===== Crossfire module methods =====
  
@@ -347,5 +353,8 @@
  Methods:
    * Next
    * Parent
  
+ ====== Scripts part of Crossfire default maps ======
  
+ Those Python scripts reside in the [[http://crossfire.svn.sourceforge.net/viewvc/crossfire/maps/trunk/python/|python]] subdirectory of the maps tree. They provide additional functionality, and may be considered as always present.
+ FIXME {describe existing ones}


IP-Address  : 213.174.127.3
Old Revision: http://wiki.metalforge.net/doku.php?id=cfpython&rev=1163610754
New Revision: http://wiki.metalforge.net/doku.php?id=cfpython

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list