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

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Thu Nov 22 16:39:03 CST 2007


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

Date        : 2007/11/22 16:39
User        : tchize
Edit Summary: method list of crossfire mudle visible in toc

@@ -46,9 +46,16 @@
  
  ===== 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 ======
+ ====== Crossfire module ======
+ 
+ To use the crossfire module, add to your python script:
+ <code python>
+ import Crossfire
+ </code>
+ 
+ 
  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 =====
@@ -78,80 +85,72 @@
  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 =====
- 
- ==== Event-related functions ====
- Those functions let the script know in what context it was called.
- 
- === WhoAmI ===
+ ===== Methods =====
+ ==== 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 ===
+ ==== 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 ===
+ ==== 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 ===
+ ==== 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 ===
+ ==== 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.
  
- === GetReturnValue ===
+ ==== GetReturnValue ====
  Return current return value.
- === SetReturnValue ===
+ ==== 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 ===
+ ==== PluginVersion ====
  Returns an integer representing the Python plugin version.
- ==== Configuration-related functions ====
- Those functions let the script know about various server settings.
- === MapDirectory ===
+ ==== 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 ===
+ ==== FindPlayer ====
  Parameter:
    * player name (string)
  
  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 ===
+ ==== 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 ===
+ ==== 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 ===
+ ==== GetParties ====
  Returns a Python ''list'' containing ''[[cfpython#crossfire.party_methods_and_attributes|Crossfire.Party]]'' objects, one for each existing party on the server.
  
- === GetRegions ===
+ ==== GetRegions ====
  Returns a Python ''list'' containing ''[[cfpython#crossfire.region_methods_and_attributes|Crossfire.Region]]'' objects, one for each region.
- === GetFriendlyList ===
+ ==== 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 ===
+ ==== GetPlayers ====
  Returns a ''list'' containing ''[[cfpython#crossfire.player_methods_and_attributes|Crossfire.Players]]'' objects, one for each player on the server
- === GetTime ===
+ ==== GetTime ====
  Returns a Python ''list'' corresponding to the in-game server time. Fields are (start at ''0'' to access):
    - year
    - month
    - day
@@ -159,56 +158,53 @@
    - minute
    - day of week
    - week of month
    - season
- === MapHasBeenLoaded ===
+ ==== 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.
  
- === FindFace ===
+ ==== FindFace ====
  Parameter:
    * face name (''String'')
  
  Returns the number of the specified face, 0 if it doesn't exist. The face name is the name as it appears in the archetypes, ie ''dcross-red1.111'', without the set name or extension.
  
- === FindAnimation ===
+ ==== FindAnimation ====
  Parameter:
    * animation name (''String'')
  
  Returns the number of the specified animation, 0 if it doesn't exist. The name is has it appears in the archetypes, ie ''campfire'' or ''bat''.
  
- ==== Action functions ====
- Those functions enable the script to manipulate runtime objects.
  
- === ReadyMap ===
+ ==== ReadyMap ====
  Loads specified map, and returns a ''Crossfire.Map'' object wrapping it. Will return ''None'' if map couldn't be found.
  
  Parameter:
    * ''String'', the map path to load
    * ''Number'', flags, optional. Combination of the following values:
      * 2: map is a player's unique map. Path is assumed to be the full path already, and it won't be changed
      * 16: map is reloaded anyway, even if it is already loaded
  
- === CreateObject ===
+ ==== CreateObject ====
  Returns an empty object which can then be manipulated and inserted in a map.
  
- === CreateObjectByName ===
+ ==== CreateObjectByName ====
  Parameters:
    * object or archetype name (''String'')
  
  Returns object with specified archetype or object name, or ''None'' if no object has the name, and archetype wasn't found.
- === CreateMap ===
+ ==== CreateMap ====
  Parameters:
    * map width (''Number'')
    * map height (''Number'')
  
  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 ====
- === Log ===
+ ==== Log ====
  Parameters:
    * level (Crossfire.LogError, Crossfire.LogInfo, Crossfire.LogDebug or Crossfire.LogMonster)
    * message (string)
  
@@ -216,9 +212,9 @@
  python build-in "print" method. Using this, scripts take advantage of Debug and Monster level which can be hidden at will by server admin (log level), and
  have access to the error level, mentioning to admin serious troubles.
  Example:
  <code>Crossfire.Log(Crossfire.LogDebug,'Player %s entered guild %s' %obj.Name %guildName)</code>
- === RegisterCommand ===
+ ==== RegisterCommand ====
  Parameters:
    * command name (string)
    * script (string)
    * speed (decimal, must be positive or 0)
@@ -229,40 +225,40 @@
  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 ===
+ ==== RegisterGlobalEvent ====
  Parameters:
    * event code (''Number'', should be one of the ''Crossfire.EventType.xxx'' constants)
  
  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.
  
  This function should not be used except in special circumstances, as Python by default registers all events anyway.
- === UnregisterGlobalEvent ===
+ ==== 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.
  
  This function should not be used, except in special circumstances, as it can disable other scripts that use those events.
- === DestroyTimer ===
+ ==== 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 ===
+ ==== 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 ===
+ ==== 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.
- === MatchString ===
+ ==== MatchString ====
  Parameters:
    * string to be searched
    * pattern to search for
  


IP-Address  : 91.177.206.171
Old Revision: http://wiki.metalforge.net/doku.php/cfpython?rev=1195509909
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