User Tools

Site Tools


wiki:data:pages:cfpython

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:data:pages:cfpython [2020/12/12 10:46]
ryo [CastAbility]
wiki:data:pages:cfpython [2023/03/04 06:43] (current)
ryo [Region] deprecate Next
Line 8: Line 8:
 Note that this guide doesn'​t intend to teach you Python. Documentation for that is available on [[http://​docs.python.org|Python'​s official web site]]. Note that this guide doesn'​t intend to teach you Python. Documentation for that is available on [[http://​docs.python.org|Python'​s official web site]].
  
-Also, advanced functions can require some knowledge of Crossfire'​s inner workings. Developers seeking help should check [[http://​crossfire.real-time.com/​development/​index.html|Crossfire'​s page on development]] or [[http://​crossfire.real-time.com/​resources/​index.html|Crossfire'​s resource page]] (which includes links to lists, IRC, how to contact people, ...). Another option is to check existing Python scripts, available in the [[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​maps/​trunk/python/|maps source tree]].+Also, advanced functions can require some knowledge of Crossfire'​s inner workings. Developers seeking help should check [[http://​crossfire.real-time.com/​development/​index.html|Crossfire'​s page on development]] or [[http://​crossfire.real-time.com/​resources/​index.html|Crossfire'​s resource page]] (which includes links to lists, IRC, how to contact people, ...). Another option is to check existing Python scripts, available in the [[https://​sourceforge.net/​p/crossfire/crossfire-maps/ci/master/tree/|maps source tree]].
  
  
 Old plugin'​s reference can be found on [[plugin_python]],​ for historical purposes. Old plugin'​s reference can be found on [[plugin_python]],​ for historical purposes.
  
-**Important note:** the API, and other parts, are valid for code's ''​trunk''​. ''​branch''​ contains hopefully all the changes too, but there may be differences. Also, links to SVN are to trunk.+**Important note:** the API, and other parts, are valid for code's ''​master''​. ''​branch''​ contains hopefully all the changes too, but there may be differences. Also, links to SVN are to trunk.
  
 +As from September, 14th, 2021, a ''​.pyi''​ file is available in ''​maps/​python/​pyi''​. It lists all available functions and variables, though functions aren't documented, so no parameters or description.
  
  
 ====== General information ====== ====== General information ======
-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?}+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 must be 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. Using a library not part of Python'​s default distribution is discouraged as this introduces new dependencies.
Line 32: Line 33:
 Data that should survive a server restart should be persisted in the ''​PlayerDirectory''​ (for specific player information) or ''​DataDirectory''​ (for regular information),​ where the server normally has write access. Data that should survive a server restart should be persisted in the ''​PlayerDirectory''​ (for specific player information) or ''​DataDirectory''​ (for regular information),​ where the server normally has write access.
  
-Scripts for server releases ​after 9 November 2007 should prefer the use of new [[cfpython#​Log|Crossfire.Log(level,​message)]] method over the python build-in print method. The reason of this is to keep coherency between python scripts messages and server logging.+Scripts for server releases ​muse use the [[cfpython#​Log|Crossfire.Log(level,​message)]] method over the python build-in print method. The reason of this is to keep coherency between python scripts messages and server logging.
  
 ===== How do I hook a script to an object? ===== ===== 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 ''​[[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​arch/​trunk/system/|/​arch/​system]]''​ directory). The fields to fill are:+Python plugin is a [[server plugin]], thus you need to insert in this object one of the //​event_xxx//​ archetype (see ''​[[https://​sourceforge.net/​p/crossfire/crossfire-arch/ci/​master/​tree/​system|/​arch/​system]]''​ directory). The fields to fill are:
   * **title**: should be //Python// to call the Python plugin.   * **title**: should be //Python// to call the Python plugin.
   * **slaying**:​ contains the path to the Python script to execute. Root refers to the map directory.   * **slaying**:​ contains the path to the Python script to execute. Root refers to the map directory.
Line 136: Line 137:
  
 The following constant types exist: The following constant types exist:
-  * ''​AttackType'':​ AT_xxx constants, as defined in ''​[[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​server/​trunk/​include/​attack.h?​view=markup|include/​attack.h]]''​ +  * ''​AttackType'':​ AT_xxx constants, as defined in ''​[[https://​sourceforge.net/​p/crossfire/crossfire-server/ci/​master/​tree/​include/​attack.h|include/​attack.h]]''​ 
-  * ''​AttackTypeNumber'':​ ATNR_xxx constants, as defined in ''​[[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​server/​trunk/include/attack.h?​view=markup|include/​attack.h]]''​ +  * ''​AttackTypeNumber'':​ ATNR_xxx constants, as defined in ''​[[https://​sourceforge.net/​p/crossfire/crossfire-server/ci/master/tree/​attack.h|include/​attack.h]]''​ 
-  * ''​CostFlag'':​ F_xxx constants, as defined in ''​[[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​server/​trunk/​include/​define.h?​view=markup|include/​define.h]]''​ (without the F_ prefix)+  * ''​CostFlag'':​ F_xxx constants, as defined in ''​[[https://​sourceforge.net/​p/crossfire/crossfire-server/ci/​master/​tree/​include/​define.h|include/​define.h]]''​ (without the F_ prefix)
   * ''​Direction'':​ contains NORTH, NORTHEAST, ..., NORTHWEST   * ''​Direction'':​ contains NORTH, NORTHEAST, ..., NORTHWEST
-  * ''​EventType'':​ EVENT_xxx constants, as defined in ''​[[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​server/​trunk/​include/​plugin.h?​view=markup|include/​plugin.h]]''​ +  * ''​EventType'':​ EVENT_xxx constants, as defined in ''​[[https://​sourceforge.net/​p/crossfire/crossfire-server/ci/​master/​tree/​include/​plugin.h|include/​plugin.h]]''​ 
-  * ''​MessageFlag'':​ NDI_xxx constants, as defined in ''​[[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​server/​trunk/​include/​newclient.h?​view=markup|include/​newclient.h]]''​ +  * ''​MessageFlag'':​ NDI_xxx constants, as defined in ''​[[https://​sourceforge.net/​p/crossfire/crossfire-server/ci/​master/​tree/​include/​newclient.h|include/​newclient.h]]''​ 
-  * ''​Move'':​ movement types, as defined in ''​[[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​server/​trunk/​include/​define.h?​view=markup|include/​define.h]]''​ +  * ''​Move'':​ movement types, as defined in ''​[[https://​sourceforge.net/​p/crossfire/crossfire-server/ci/​master/​tree/​include/​define.h|include/​define.h]]''​ 
-  * ''​Type'':​ object type, as defined in ''​[[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​server/​trunk/​include/​define.h?​view=markup|include/​define.h]]''​ +  * ''​Type'':​ object type, as defined in ''​[[https://​sourceforge.net/​p/crossfire/crossfire-server/ci/​master/​tree/​include/​define.h|include/​define.h]]''​ 
-  * ''​ReplyType'':​ the rt_xxx constants, reply type, as defined in ''​[[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​server/​trunk/​include/​define.h?​view=markup|include/​dialog.h]]''​ +  * ''​ReplyType'':​ the rt_xxx constants, reply type, as defined in ''​[[https://​sourceforge.net/​p/crossfire/crossfire-server/ci/​master/​tree/​include/​define.h|include/​dialog.h]]''​ 
-  * ''​AttackMovement'':​ the various DISTATT, PETMOVE and other constants in the "​MONSTER_MOVEMENT"​ group as defined in [[http://crossfire.svn.sourceforge.net/​viewvc/​crossfire/​server/​trunk/​include/​define.h?​view=markup|include/​define.h]]+  * ''​AttackMovement'':​ the various DISTATT, PETMOVE and other constants in the "​MONSTER_MOVEMENT"​ group as defined in [[https://​sourceforge.net/​p/crossfire/crossfire-server/ci/​master/​tree/​include/​define.h|include/​define.h]]
  
  
Line 412: Line 413:
  
 Properties in **bold** are read-write, others are read-only. Most properties are mapped to fields of the ''​object''​ structure. ''​Boolean''​ values are mapped to the various flags. Properties in **bold** are read-write, others are read-only. Most properties are mapped to fields of the ''​object''​ structure. ''​Boolean''​ values are mapped to the various flags.
-  * **Name**: ''​String''​ containing the object'​s name +  * **Name**: ''​String''​ containing the object'​s name, adjusted for the number of objects. Settings this property changes both the singular and plural names 
-  * **NamePl**: ''​String''​ containing the object'​s plural name+  * **NamePl**: ''​String''​ containing the object'​s plural ​name. Changing this property only changes the item's plural name 
 +  * NameSingular:​ ''​String''​ containing the object'​s singular ​name
   * **Title**: ''​String''​   * **Title**: ''​String''​
   * **Race**: ''​String''​   * **Race**: ''​String''​
Line 472: Line 474:
   * Identified: ''​Boolean''​   * Identified: ''​Boolean''​
   * **Alive**: ''​Boolean''​   * **Alive**: ''​Boolean''​
-  * DungeonMaster:​ ''​Boolean''​+  ​* **DungeonMaster**: ''​Boolean'',​ writable on ''​master''​
   * WasDungeonMaster:​ ''​Boolean''​   * WasDungeonMaster:​ ''​Boolean''​
   * **Applied**:​ ''​Boolean''​   * **Applied**:​ ''​Boolean''​
Line 593: Line 595:
  
 Arguments: Arguments:
-  * ''​Crossfire.Object''​ representing the spell to case+  * ''​Crossfire.Object''​ representing the spell to cast
   * ''​Crossfire.Direction'',​ direction in which the object should cast   * ''​Crossfire.Direction'',​ direction in which the object should cast
   * ''​String'',​ optional arguments to the spell (for food creation, ...)   * ''​String'',​ optional arguments to the spell (for food creation, ...)
Line 1064: Line 1066:
   * Longname: ''​String''​   * Longname: ''​String''​
   * Message: ''​String''​   * Message: ''​String''​
-  * Next: ''​Crossfire.Region''​+  * <del>Next: ''​Crossfire.Region''​</​del>​ deprecated, will be ''​None''​ on master branch
   * JailX, JailY: ''​Integer'',​ coordinates of the jail for this region (trunk only)   * JailX, JailY: ''​Integer'',​ coordinates of the jail for this region (trunk only)
   * JailPath: ''​String'',​ path of the jail for this region (trunk only)   * JailPath: ''​String'',​ path of the jail for this region (trunk only)
wiki/data/pages/cfpython.1607791600.txt.gz · Last modified: 2020/12/12 10:46 by ryo