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

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Fri Apr 20 12:09:25 CDT 2007


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

Date        : 2007/04/20 12:09
User        : ryo
Edit Summary: format, order, and such

@@ -3,270 +3,232 @@
  The latest version, 2.0, is a major rewrite which introduces Python objects to represent maps, Crossfire objects and players. The hooking system also changed.
  
  Old plugin's reference can be found on [[plugin_python]].
  
- **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.
+ **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.
  
  ====== 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?}
  
  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 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 data persisted through those functions 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 regular information), where 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 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:
+ 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:
    * **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.
  
  A script can then use ''WhoAmI()'', ''WhoIsActivator()'', ''WhoIsOther()'', ''WhatIsMessage()'' functions of the ''Crossfire'' module to find the executing context.
- 
  
  ===== How do I hook a script to a global event? =====
- 
  Create a script, and put it in the ''/python/events/xxx'' subdirectory or the ''maps'' directory, where ''xxx'' is the event's name in lowercase (create the directory if it doesn't exist). Available events are listed [[server_plugin#Hooking to global events|on the server_plugin page]].
- 
- In addition, there is a special event, ''init'', which is called just after the plugin has been loaded. It behaves like other events in every aspect.
- 
+ In addition, there is a special event, ''init'', which is called just after the plugin has been loaded. It behaves like other events in every aspect, but is called only once when the plugin finished loading.
  
  ===== How do I register a custom command? =====
- 
  Check ''[[cfpython#RegisterCommand|Crossfire.RegisterCommand]]''.
- 
  
  ===== Return value =====
- 
  The return value of the script can be manipulated through the ''[[cfpython#GetReturnValue|GetReturnValue]]'' and ''[[cfpython#SetReturnValue|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, without specific prefix (ie F_TRUE becomes TRUE, AT_FIRE becomes FIRE).
+ They are available through ''Crossfire.xxx.VALUE'', where ''xxx'' is the constant type and ''VALUE'' the value as in the C source code, in uppercase, without specific prefix (ie F_TRUE becomes TRUE, AT_FIRE becomes FIRE, and so on).
  
  For each constant group ''xxx'' there exists a ''xxxName'' dictionary object containing the name of the value as a string.
  
  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]]''
+   * ''AttackTypeNumber'': ATNR_xxx constants, as defined in ''[[http://crossfire.svn.sourceforge.net/viewvc/crossfire/server/trunk/include/attack.h?view=markup|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)
    * ''Direction'': contains NORTH, NORTHEAST, ..., NORTHWEST
-   * ''Type'': object type, as defined in ''include/define.h''
-   * ''Move'': movement types, as defined in ''include/define.h''
-   * ''MessageFlag'': NDI_xxx constants, as defined in ''include/newclient.h''
-   * ''CostFlag'': F_xxx constants, as defined in ''include/define.h'' (without the F_ prefix)
-   * ''AttackType'': AT_xxx constants, as defined in ''include/attack.h''
-   * ''AttackTypeNumber'': ATNR_xxx constants, as defined in ''include/attack.h''
-   * ''EventType'': EVENT_xxx constants, as defined in ''include/plugin.h''
- 
+   * ''EventType'': EVENT_xxx constants, as defined in ''[[http://crossfire.svn.sourceforge.net/viewvc/crossfire/server/trunk/include/plugin.h?view=markup|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]]''
+   * ''Move'': movement types, 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 ''[[http://crossfire.svn.sourceforge.net/viewvc/crossfire/server/trunk/include/define.h?view=markup|include/define.h]]''
  {FIXME} do a nice table, with link to values?
- 
  Example:
  <code>
  whoami.Say("%s => %d"%(Crossfire.DirectionName[Crossfire.Direction.NORTH], Crossfire.Direction.NORTH))
  </code>
  will write <code>NORTH => 1</code>
  
  **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.
- 
- 
  
  ===== Crossfire module methods =====
  
- ==== WhoAmI ====
- Returns the ''Crossfire.Object'' from which the event being handled was raised, corresponds to the "op" parameter of the event. Can be ''None''. For a map event, this is a ''Crossfire.Map'' 
+ ==== Event-related functions ====
+ Those functions let the script know in what context it was called.
  
+ === WhoAmI ===
+ Returns the ''Crossfire.Object'' from which the event being handled was raised, corresponds to the ''[[server_plugin#Hooking to an object-specific event|op]]'' parameter of the event. Can be ''None''. For a map event, this is a ''Crossfire.Map''
  
- ==== WhoIsActivator ====
- Returns the ''Crossfire.Object'' having caused the event being handled, corresponds to the "activator" parameter of the event. Can be ''None''.
+ === WhoIsActivator ===
+ Returns the ''Crossfire.Object'' having caused the event being handled, corresponds to the ''[[server_plugin#Hooking to an object-specific event|activator]]'' parameter of the event. Can be ''None''.
  
- ==== WhoIsOther ====
- Returns the ''Crossfire.Object'' being part of the event, corresponds to the "third" parameter of the event. Can be ''None''.
- 
- ==== WhatIsMessage ====
- Returns the ''String'' that was sent as part of the event, corresponds to the "message" parameter of the event.
- 
- ==== ScriptName ====
+ === WhoIsOther ===
+ Returns the ''Crossfire.Object'' being part of the event, corresponds to the ''[[server_plugin#Hooking to an object-specific event|third]]'' parameter of the event. Can be ''None''.
+ === WhatIsMessage ===
+ Returns the ''String'' that was sent as part of the event, corresponds to the ''[[server_plugin#Hooking to an object-specific event|message]]'' parameter of the event.
+ === ScriptName ===
  Returns the absolute path of the currently executing script.
- 
- ==== ScriptParameters ====
+ === ScriptParameters ===
  This ''String'' variable contains:
    * for a global event, the name of the event (''born'', ''gkill'', ...)
    * for an event hooked to an object, the ''name'' field of the object
    * for a custom command, the parameters the player sent
- 
- ==== WhatIsEvent ====
+ === WhatIsEvent ===
  ''Crossfire.Object'' representing the event object that links to the plugin. Will be ''None'' for global events and custom commands.
  
- ==== MapDirectory ====
+ === GetReturnValue ===
+ Return current return value.
+ === SetReturnValue ===
+ Parameters:
+   * return value (integer)
+ 
+ Sets the value the plugin will return to the server when the script exits. Value and effect depend on the event being handled.
+ === PluginVersion ===
+ Returns an integer representing the Python plugin version.
+ ==== Configuration-related functions ====
+ Those functions let the script know about various server settings.
+ === MapDirectory ===
  Returns the system directory containing the maps. Note that it is relative to the ''Data'' directory.
- 
- ==== UniqueDirectory ====
+ === UniqueDirectory ===
  Returns the system directory where unique items and maps are stored.
- 
- ==== TempDirectory ====
+ === TempDirectory ===
  Returns the system directory where temporary files are stored.
- 
- ==== ConfigDirectory ====
+ === ConfigDirectory ===
  Returns the system directory containing configuration files.
- 
- ==== LocalDirectory ====
+ === LocalDirectory ===
  Returns the system directory containing read/write files.
- 
- ==== PlayerDirectory ====
+ === PlayerDirectory ===
  Returns the system directory containing player files.
- 
- ==== DataDirectory ====
+ === DataDirectory ===
  Returns the system directory containing read-only data.
+ ==== Data access functions ====
+ Those functions enable the script to browse runtime data and objects (maps, players, ...).
+ === FindPlayer ===
+ Parameter:
+   * player name (string)
  
- ==== ReadyMap ====
+ Returns a ''[[cfpython#crossfire.player_methods_and_attributes|Crossfire.Player]]'' object for specified player, based on partial name matching, or ''None'' if not found. If only one player name can match, return this player, else return ''None''.
+ === GetArchetypes ===
+ Returns a Python ''list'' containing ''[[cfpython#crossfire.archetype_methods_and_attributes|Crossfire.Archetype]]'' objects representing all archetypes the server knows. Should not be called lightly, as this can take some time.
+ === GetMaps ===
+ Returns a Python ''list'' containing ''[[cfpython#crossfire.map_methods_and_attributes|Crossfire.Map]]'' objects, one for each map currently being loaded. This includes random and unique maps.
+ === GetParties ===
+ Returns a Python ''list'' containing ''[[cfpython#crossfire.party_methods_and_attributes|Crossfire.Party]]'' objects, one for each existing party on the server.
+ 
+ === GetRegions ===
+ Returns a Python ''list'' containing ''[[cfpython#crossfire.region_methods_and_attributes|Crossfire.Region]]'' objects, one for each region.
+ === GetFriendlyList ===
+ Returns a ''list'' of ''[[cfpython#crossfire.object_methods_and_attributes|Crossfire.Object]]'' representing all items on the friendly list. Individual objects can be added/removed through their ''Friendly'' flag.
+ === GetPlayers ===
+ Returns a ''list'' containing ''[[cfpython#crossfire.player_methods_and_attributes|Crossfire.Players]]'' objects, one for each player on the server
+ === GetTime ===
+ Returns a Python ''list'' corresponding to the in-game server time. Fields are (start at ''0'' to access):
+   - year
+   - month
+   - day
+   - hour
+   - minute
+   - day of week
+   - week of month
+   - season
+ === MapHasBeenLoaded ===
+ Parameter:
+   * map path (''String'')
+ 
+ Returns the ''[[cfpython#crossfire.map_methods_and_attributes|Crossfire.Map]]'' with specified path, or ''None'' if such a map isn't loaded. Will not try to load the map, see ''[[cfpython#readymap|Crossfire.ReadyMap]]'' for that.
+ ==== Action functions ====
+ Those functions enable the script to manipulate runtime objects.
+ === ReadyMap ===
  Parameter:
    * map name (''String'')
    * optional: flags (''Number'')
- 
  Loads specified map, and returns a ''Crossfire.Map'' object wrapping it. Will return ''None'' if map couldn't be found.
  
  ''Flags'' specifies what kind of map should be loaded. It matches the 2nd argument of ''ready_map_name()'' {FIXME} add flags and such
- 
- ==== FindPlayer ====
- Parameter:
-   * player name (string)
- 
- Returns a ''Crossfire.Player'' object for specified player, based on partial name matching, or ''None'' if not found. If only one player name can match, return this player, else return ''None''.
- 
- ==== MatchString ====
+ === CreateObject ===
+ Returns an empty object which can then be manipulated and inserted in a map.
+ === CreateObjectByName ===
  Parameters:
-   * string to be searched
-   * pattern to search for
+   * object or archetype name (''String'')
  
- Returns ''1'' if string matches the pattern, ''0'' else.
- 
- Pattern can be a regular expression FIXME specifications
- 
- ==== GetReturnValue ====
- Return current return value.
- 
- ==== SetReturnValue ====
+ Returns object with specified archetype or object name, or ''None'' if no object has the name, and archetype wasn't found.
+ === CreateMap ===
  Parameters:
-   * return value (integer)
+   * map width (''Number'')
+   * map height (''Number'')
  
- Sets the value the plugin will return to the server when the script exits. Value and effect depend on the event being handled.
- 
- ==== PluginVersion ====
- Returns an integer representing the Python plugin version.
- 
- ==== CreateObject ====
- Returns an empty object which can then be manipulated and inserted in map.
- 
- ==== CreateObjectByName ====
- Parameters:
-   * object or archetype name (string)
- 
- Returns object with specified name or archetype, or ''None'' if no object has the name, and archetype wasn't found.
- 
- ==== GetPrivateDictionary ====
- Returns a Python ''dictionary'' the script can use to store data between runs. This data is not shared with other scripts.
- 
- Note that data will be lost in case of server restart.
- 
- ==== GetSharedDictionary ====
- Returns a Python ''dictionary'' the script can use to share data with other scripts.
- 
- Note that data will be lost in case of server restart.
- 
- ==== GetArchetypes ====
- Returns a Python ''list'' containing ''Crossfire.Archetype'' objects representing all archetypes the server knows. Should not be called lightly, as this can take some time.
- 
- ==== GetMaps ====
- Returns a Python ''list'' containing ''[[cfpython#Crossfire.Map methods and attributes|Crossfire.Map]]'' objects, one for each map currently being loaded. This includes random and unique maps.
- 
- ==== GetParties ====
- Returns a Python ''list'' containing ''Crossfire.Party'' objects, one for each existing party on the server.
- 
- 
- ==== GetRegions ====
- Returns a Python ''list'' containing ''[[cfpython#Crossfire.Region methods and attributes|Crossfire.Region]]'' objects, one for each region.
- 
- 
- ==== RegisterCommand ====
+ Returns an empty map of specified dimensions. Unless map is removed immediately, ''Path'' should be set so the map correctly displays in the ''maps'' output.
+ ==== Misc functions ====
+ === RegisterCommand ===
  Parameters:
    * command name (string)
    * script (string)
    * speed (decimal, must be positive or 0)
  
  Registers a server command which will be mapped to specified script. See [[server plugin#Registering a command]] for more information.
  
  The script path is relative to the ''maps'' subdirectory.
- 
  When the command is called, the following methods will provide information:
    * ''WhoAmI'' contains the player
    * ''ScriptName'' contains the currently executing script's name
    * ''ScriptParameters'' contains any parameter the player added to the command. FIXME {can NULL be passed?}
+ === RegisterGlobalEvent ===
+ Parameters:
+   * event code (''Number'', should be one of the ''Crossfire.EventType.xxx'' constants)
  
- ==== RegisterGlobalEvent ====
- ==== UnregisterGlobalEvent ====
+ This instructs the server to call the Python plugin for all events of specified type. Python will then call scripts in the ''/python/events/xxx'' directory, where ''xx'' is the event's name.
  
- ==== GetTime ====
- Returns a Python ''list'' corresponding to the in-game server time. Fields are (start at ''0'' to access):
-   - year
-   - month
-   - day
-   - hour
-   - minute
-   - day of week
-   - week of month
-   - season
+ This function should not be used except in special circumstances, as Python by default registers all events anyway.
+ === UnregisterGlobalEvent ===
+ Parameters:
+   * event code (''Number'', should be one of the ''Crossfire.EventType.xxx'' constants)
  
+ This instructs the server to stop calling the Python plugin for all events of specified type.
  
- 
- ==== DestroyTimer ====
+ This function should not be used, except in special circumstances, as it can disable other scripts that use those events.
+ === DestroyTimer ===
  Removes a timer created through a call to ''[[cfpython#AddTimer|Crossfire.Object.AddTimer]]''.
  
  Arguments:
    * ''Number'': timer identifier.
  
  Returns:
    * 0: no error.
    * -1: invalid timer identifier.
+ === GetPrivateDictionary ===
+ Returns a Python ''dictionary'' the script can use to store data between runs. This data is not shared with other scripts.
  
- ==== GetFriendlyList ====
- Returns a ''list'' of ''[[cfpython#crossfire.object_methods_and_attributes|Crossfire.Object]]'' representing all items on the friendly list. Individual objects can be added/removed through their ''Friendly'' flag.
+ Note that data will be lost in case of server restart.
+ === GetSharedDictionary ===
+ Returns a Python ''dictionary'' the script can use to share data with other scripts.
  
- ==== MapHasBeenLoaded ====
- Parameter:
-   * map path (''String'')
- 
- Returns the ''[[cfpython#crossfire.map_methods_and_attributes|Crossfire.Map]]'' with specified path, or ''None'' if such a map isn't loaded. Will not try to load the map, see ''[[cfpython#readymap|Crossfire.ReadyMap]]'' for that.
- 
- ==== CreateMap ====
+ Note that data will be lost in case of server restart.
+ === MatchString ===
  Parameters:
-   * map width (''Number'')
-   * map height (''Number'')
+   * string to be searched
+   * pattern to search for
  
- Returns an empty map of specified dimensions. Unless map is removed immediately, ''Path'' should be set so the map correctly displays in the ''maps'' output.
- 
- ==== GetPlayers ====
- 
- Returns a ''list'' containing Crossfire.Players objects, one for each player on the server
+ Returns ''1'' if string matches the pattern, ''0'' else.
  
+ Pattern can be a regular expression FIXME specifications
  ===== Crossfire.Archetype methods and attributes =====
- 
  This represents an archetype, from which all objects are derived.
- 
  Pointer to such item can be obtained through the ''Crossfire.Object.Archetype'' or the list returned by ''Crossfire.GetArchetypes()''.
  
  Properties:
    * Clone: returns a ''Crossfire.Object'' representing the default values for items of that archetype. Will never be ''None''
@@ -276,15 +238,11 @@
    * More: next archetype linked to current archetype. Will be ''None'' for last item
  
  Methods:
    * NewObject: returns a ''Crossfire.Object'' having this archetype as type
- 
  ===== Crossfire.Object methods and attributes =====
- 
  FIXME link to dev:objects 's fields? split flag & such info. Make a table with property / mapping to object / Python type
- 
  Properties in **bold** are read-write, others are readonly. 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
    * **NamePl**: ''String'' containing the object's plural name
    * **Title**: ''String''
    * **Map**: ''[[cfpython#Crossfire.Map methods and attributes|Crossfire.Map]]'' containing the map the object is in. Changing that teleports the object to specified map, at default coordinates.
@@ -402,19 +360,15 @@
    * Count
    * **GodGiven**: ''Boolean''
    * **IsPet**: if the object is on the friendly list or not
    * **AttackMovement**
- 
  ==== Methods ====
- 
  FIXME document all parameters. Link to relevant Crossfire function. Split in "standard function" and "helper function"?
- 
  === ActivateRune ===
  Current object springs like a trap, hitting the victim.
  
  Arguments:
    * ''Crossfire.Object'' that is the victim of the trap.
- 
  === AddExp ===
  Adds or substracts experience to current object.
  
  Arguments:
@@ -424,21 +378,18 @@
      * 0: give the player the skill
      * 1: give player exp to total, no skill
      * 2: player gets nothing
      * 3: used when removing exp
- 
  === AddTimer ===
- 
- Fires an ''event_timer'' after the specified delay. Object must have a handler for this event.
+ Fires an ''event_timer'' after the specified delay. Object should have a handler for this event.
  
  Arguments:
    * ''number'', delay for timer
    * ''number'', timer mode
      * 1: delay is in seconds
      * 2: delay is in server cycles
  
  Returns: timer identifier, which can be used to remove the timer through a call to ''[[cfpython#DestroyTimer|Crossfire.DestroyTimer]]''
- 
  === Apply ===
  Current object applies specified object. The effect depends on the object being applied, which can be a potion, a trigger, ...
  
  Arguments:
@@ -448,79 +399,64 @@
  Return value:
    * 0: player or monster can't apply objects of that type
    * 1: has been applied, or there was an error applying the object
    * 2: objects of that type can't be applied if not in inventory
- 
  === Cast ===
  === CastAbility ===
  === CheckArchInventory ===
  === CheckInventory ===
  === CheckTrigger ===
  === CreateObject ===
- 
  === Drop ===
  Current object drops specified object, which will be put on the ground, or in a container, depending on applied containers.
  
  Argument:
    * ''Crossfire.Object'' to drop
- 
  === Fix ===
  Current object is reinitialized from its default values, values (ac, wc, Str, ...) are recomputed from items worn, in inventory, ...
- 
  === ForgetSpell ===
  === GetResist ===
  Gets the value of a resistance to an attacktype.
  
  Arguments:
    * ''Number'': attacktype for which to get the resistance
  
  Return: ''Number'' with the value. Note that an invalid attacktype will return 0, which can't be distinguished from a neutral resistance.
- 
  === InsertInto ===
  === KnowSpell ===
  === LearnSpell ===
  === OutOfMap ===
  === Pay ===
  === PayAmount ===
  === QueryCost ===
  === QueryName ===
- 
  Return: ''String'' containing the object's full name.
- 
  === ReadKey ===
  Reads key associated to value.
  
  Arguments:
    * ''String'': key value to read
  
  Return: ''String'' containing the value. Will be empty if NULL value.
- 
  === Remove ===
- 
  Destroys current object, which then becomes invalid.
- 
  === Reposition ===
- 
  === Say ===
  Current object says something in current map.
  
  Argument:
    * ''string'' to say.
- 
  === Speak ===
  Current object says something in current map
- 
  FIXME difference with say??
  
  Argument:
    * ''string'' to say.
- 
  === Take ===
  Current object picks up specified object, which will be put in inventory, or in a container, depending on applied containers.
  
  Argument:
    * ''Crossfire.Object'' to take
- 
  === Teleport ===
  Teleports the object to specified place.
  
  Arguments:
@@ -528,21 +464,17 @@
    * ''Number'': x coordinates
    * ''Number'': y coordinates
  
  Return value: ''Number'', 0 for success, 1 for failure.
- 
  === WriteKey ===
  Inserts specified key/value in the object.
  
  Arguments:
    * ''String'': key value
    * ''String'': value to associate to the key
    * ''Number'' (optional): 0 to only update the key and not insert it, non zero to add it anyway
- 
  ===== Crossfire.Map methods and attributes =====
- 
  Properties in **bold** are read-write, others read only.
- 
    * Difficulty: ''Number''
    * **Path**: ''String''
    * TempName: ''String''
    * Name: ''String''
@@ -568,15 +500,13 @@
    * Exists (special meaning, ''False'' if cf map has been freed from memory, ''True'' otherwise)
  
  Methods:
    * Print: argument are ''String'', optional ''Number''. Prints the specified message to all players on the map, with specified flags (default is NDI_BLUE|NDI_UNIQUE). {FIXME} add flag description / equivalent of ext_info_map().
-   * ObjectAt
-   * CreateObject
+   * ObjectAt: arguments are ''x'' and ''y''. Returns the first ''Crossfire.Object'' at specified location, other objects available through the use of the ''Above'' field
+   * CreateObject: arguments are ''name'', ''x'' and ''y''. Equivalent of calling ''Crossfire.CreateObjectByName()'' (creates an item from archetype or name) and insert it in the map at the specified location
    * Check
    * ChangeLight: argument is a ''Number'', specifying how to change the light. Negative value means map gets brighter, positive darker. Note that light will never be negative or over 5 (''MAX_DARKNESS'')
- 
  ===== Crossfire.Player methods and attributes =====
- 
  This class inherits from Crossfire.Object, and introduces the new properties (bold = read-write):
    * IP: ''String''.
    * **BedMap**: ''string'' containing the map in which the player last saved.
    * **BedX** : ''number'' containing the x coordinate of last savebed.
@@ -585,22 +515,17 @@
    * **Party**: ''Crossfire.Party'', party in which the player is. Note that changing it bypasses a potential party's password.
  and methods:
    * Message
    * Write
- 
- 
  
  ===== Crossfire.Party methods and attributes =====
- 
  This class merely encapsulates a party. Everything is read-only. Attributes:
    * Name: ''String''
    * Password: ''String''
    * Next: ''Crossfire.Party''
+ 
  Methods:
    * GetPlayers: ''list'' of ''Crossfire.Players''
- 
- 
- 
  ===== Crossfire.Region methods and attributes =====
  This class encapsulates an ingame region. Properties are read-only.
    * Name: ''String''
    * Longname: ''String''
@@ -608,19 +533,15 @@
    * Next: ''Crossfire.Region''
  
  Methods:
    * Parent: returns a ''Crossfire.Region''
- 
  ====== 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}
- 
  ===== /python/misc/death_message.py =====
- This script makes the monster/living thing containing it display a message when it dies.
+ This script makes the monster/living thing containing it display a message when it dies. It should be hooked through an ''event_death'' archetype in monster's inventory.
  
  Message is specified in event object's options field. It can contain %m and %k, which will be replaced by respectively dead item's name and killer's name (if no killer, replaced by an empty string).
- 
  ===== /python/misc/greet_message.py =====
- This script makes the monster/living thing containing it display a message when it attacks for the first time an enemy.
+ This script makes the monster/living thing containing it display a message when it attacks for the first time an enemy. It should be hooked through an ''event_time'' archetype in monster's inventory.
  
  Message is specified in event object's options field. It can contain %m and %e, which will be replaced by respectively monster's name and enemy's name.


IP-Address  : 82.236.87.204
Old Revision: http://wiki.metalforge.net/doku.php/cfpython?rev=1176842572
New Revision: http://wiki.metalforge.net/doku.php/cfpython

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




More information about the crossfire-wiki mailing list