Atrinik Server  4.0
Data Structures | Typedefs | Functions | Variables
plugin_python.c File Reference
#include <plugin_python.h>
#include <toolkit/packet.h>
#include <player.h>
#include <object.h>
#include <object_methods.h>
#include <compile.h>
#include <eval.h>
#include <node.h>

Go to the source code of this file.

Data Structures

struct  python_eval_struct
 

Typedefs

typedef struct python_eval_struct python_eval_struct
 

Functions

static void initContextStack (void)
 
static void pushContext (PythonContext *context)
 
static PythonContextpopContext (void)
 
static void freeContext (PythonContext *context)
 
static PyObject * py_runfile (const char *path, PyObject *globals, PyObject *locals)
 
static void py_runfile_simple (const char *path, PyObject *locals)
 
static void PyErr_LOG (void)
 
static PyCodeObject * compilePython (char *filename)
 
static int do_script (PythonContext *context, const char *filename)
 
static void command_custom_python (object *op, const char *command, char *params)
 
static PyObject * Atrinik_LoadObject (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_ReadyMap (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_FindPlayer (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_PlayerExists (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_WhoAmI (PyObject *self)
 
static PyObject * Atrinik_WhoIsActivator (PyObject *self)
 
static PyObject * Atrinik_WhoIsOther (PyObject *self)
 
static PyObject * Atrinik_WhatIsEvent (PyObject *self)
 
static PyObject * Atrinik_GetEventNumber (PyObject *self)
 
static PyObject * Atrinik_WhatIsMessage (PyObject *self)
 
static PyObject * Atrinik_GetOptions (PyObject *self)
 
static PyObject * Atrinik_GetReturnValue (PyObject *self)
 
static PyObject * Atrinik_SetReturnValue (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_GetEventParameters (PyObject *self)
 
static PyObject * Atrinik_RegisterCommand (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_CreatePathname (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_GetTime (PyObject *self)
 
static PyObject * Atrinik_FindParty (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_Logger (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_GetRangeVectorFromMapCoords (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_CostString (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_CacheAdd (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_CacheGet (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_CacheRemove (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_GetFirst (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_CreateMap (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_CreateObject (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_GetTicks (PyObject *self)
 
static PyObject * Atrinik_GetArchetype (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_print (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_Eval (PyObject *self, PyObject *args)
 
static PyObject * Atrinik_GetSettings (PyObject *self)
 
static PyObject * Atrinik_Process (PyObject *self)
 
static int handle_event (va_list args)
 
static int handle_map_event (va_list args)
 
static int handle_global_event (int event_type, va_list args)
 
static int handle_unit_event (va_list args)
 
MODULEAPI void * triggerEvent (int *type,...)
 
MODULEAPI void getPluginProperty (int *type,...)
 
MODULEAPI void postinitPlugin (void)
 
static PyObject * module_create (PyObject *parent, const char *name)
 
static void module_add_constants (PyObject *module, const char *name, const Atrinik_Constant *consts, const char *doc)
 
static void module_add_array (PyObject *module, const char *name, void *array, size_t array_size, field_type type)
 
MODULEAPI void initPlugin (struct plugin_hooklist *hooklist)
 
MODULEAPI void closePlugin (void)
 
static int set_face_field (void *ptr, long face_id)
 
static int set_animation_field (void *ptr, long anim_id)
 
int generic_field_setter (fields_struct *field, void *ptr, PyObject *value)
 
PyObject * generic_field_getter (fields_struct *field, void *ptr)
 
PyObject * generic_rich_compare (int op, int result)
 
int python_call_int (PyObject *callable, PyObject *arglist)
 

Variables

struct plugin_hooklist * hooks
 
PyObject * AtrinikError
 
static PythonContextcontext_stack
 
PythonContextcurrent_context
 
static PyObject * py_globals_dict = NULL
 
static python_eval_structpython_eval
 
static const char package_doc []
 
static const char module_doc_type []
 
static const char module_doc_gender []
 
static const Atrinik_Constant constants []
 
static const Atrinik_Constant constants_types []
 
static const Atrinik_Constant constants_gender []
 
static const char *const constants_colors [][2]
 
static python_cache_entrypython_cache = NULL
 
static const char doc_Atrinik_LoadObject []
 
static const char doc_Atrinik_ReadyMap []
 
static const char doc_Atrinik_FindPlayer []
 
static const char doc_Atrinik_PlayerExists []
 
static const char doc_Atrinik_WhoAmI []
 
static const char doc_Atrinik_WhoIsActivator []
 
static const char doc_Atrinik_WhoIsOther []
 
static const char doc_Atrinik_WhatIsEvent []
 
static const char doc_Atrinik_GetEventNumber []
 
static const char doc_Atrinik_WhatIsMessage []
 
static const char doc_Atrinik_GetOptions []
 
static const char doc_Atrinik_GetReturnValue []
 
static const char doc_Atrinik_SetReturnValue []
 
static const char doc_Atrinik_GetEventParameters []
 
static const char doc_Atrinik_RegisterCommand []
 
static const char doc_Atrinik_CreatePathname []
 
static const char doc_Atrinik_GetTime []
 
static const char doc_Atrinik_FindParty []
 
static const char doc_Atrinik_Logger []
 
static const char doc_Atrinik_GetRangeVectorFromMapCoords []
 
static const char doc_Atrinik_CostString []
 
static const char doc_Atrinik_CacheAdd []
 
static const char doc_Atrinik_CacheGet []
 
static const char doc_Atrinik_CacheRemove []
 
static const char doc_Atrinik_GetFirst []
 
static const char doc_Atrinik_CreateMap []
 
static const char doc_Atrinik_CreateObject []
 
static const char doc_Atrinik_GetTicks []
 
static const char doc_Atrinik_GetArchetype []
 
static const char doc_Atrinik_print []
 
static const char doc_Atrinik_Eval []
 
static const char doc_Atrinik_GetSettings []
 
static const char doc_Atrinik_Process []
 
static PyMethodDef AtrinikMethods []
 

Detailed Description

Atrinik python plugin.

Author
Alex Tokar
Yann Chachkoff

Definition in file plugin_python.c.

Typedef Documentation

Structure used to evaluate code in the main thread after a specified delay.

Can also be used to execute code from other threads with no ill effects.

Function Documentation

static PyObject* Atrinik_CacheAdd ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.CacheAdd() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1553 of file plugin_python.c.

static PyObject* Atrinik_CacheGet ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.CacheGet() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1586 of file plugin_python.c.

static PyObject* Atrinik_CacheRemove ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.CacheRemove() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1633 of file plugin_python.c.

static PyObject* Atrinik_CostString ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.CostString() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1520 of file plugin_python.c.

static PyObject* Atrinik_CreateMap ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.CreateMap() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1719 of file plugin_python.c.

static PyObject* Atrinik_CreateObject ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.CreateObject() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1753 of file plugin_python.c.

static PyObject* Atrinik_CreatePathname ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.CreatePathname() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1323 of file plugin_python.c.

static PyObject* Atrinik_Eval ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.Eval() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1871 of file plugin_python.c.

static PyObject* Atrinik_FindParty ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.FindParty() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1405 of file plugin_python.c.

static PyObject* Atrinik_FindPlayer ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.FindPlayer() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 975 of file plugin_python.c.

static PyObject* Atrinik_GetArchetype ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.GetArchetype() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1801 of file plugin_python.c.

static PyObject* Atrinik_GetEventNumber ( PyObject *  self)
static

Implements Atrinik.GetEventNumber() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1129 of file plugin_python.c.

static PyObject* Atrinik_GetEventParameters ( PyObject *  self)
static

Implements Atrinik.GetEventParameters() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1262 of file plugin_python.c.

static PyObject* Atrinik_GetFirst ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.GetFirst() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1678 of file plugin_python.c.

static PyObject* Atrinik_GetOptions ( PyObject *  self)
static

Implements Atrinik.GetOptions() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1180 of file plugin_python.c.

static PyObject* Atrinik_GetRangeVectorFromMapCoords ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.GetRangeVectorFromMapCoords() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1478 of file plugin_python.c.

static PyObject* Atrinik_GetReturnValue ( PyObject *  self)
static

Implements Atrinik.GetReturnValue() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1203 of file plugin_python.c.

static PyObject* Atrinik_GetSettings ( PyObject *  self)
static

Implements Atrinik.GetSettings() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1930 of file plugin_python.c.

static PyObject* Atrinik_GetTicks ( PyObject *  self)
static

Implements Atrinik.GetTicks() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1782 of file plugin_python.c.

static PyObject* Atrinik_GetTime ( PyObject *  self)
static

Implements Atrinik.GetTime() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1358 of file plugin_python.c.

static PyObject* Atrinik_LoadObject ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.LoadObject() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 918 of file plugin_python.c.

static PyObject* Atrinik_Logger ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.Logger() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1430 of file plugin_python.c.

static PyObject* Atrinik_PlayerExists ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.PlayerExists() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1005 of file plugin_python.c.

static PyObject* Atrinik_print ( PyObject *  self,
PyObject *  args 
)
static

Implements print() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1830 of file plugin_python.c.

static PyObject* Atrinik_Process ( PyObject *  self)
static

Implements Atrinik.Process() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 2004 of file plugin_python.c.

static PyObject* Atrinik_ReadyMap ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.ReadyMap() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 946 of file plugin_python.c.

static PyObject* Atrinik_RegisterCommand ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.RegisterCommand() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1293 of file plugin_python.c.

static PyObject* Atrinik_SetReturnValue ( PyObject *  self,
PyObject *  args 
)
static

Implements Atrinik.SetReturnValue() Python method.

Parameters
selfSelf object for methods; module object for module functions.
argsArguments.

Definition at line 1226 of file plugin_python.c.

static PyObject* Atrinik_WhatIsEvent ( PyObject *  self)
static

Implements Atrinik.WhatIsEvent() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1105 of file plugin_python.c.

static PyObject* Atrinik_WhatIsMessage ( PyObject *  self)
static

Implements Atrinik.WhatIsMessage() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1157 of file plugin_python.c.

static PyObject* Atrinik_WhoAmI ( PyObject *  self)
static

Implements Atrinik.WhoAmI() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1035 of file plugin_python.c.

static PyObject* Atrinik_WhoIsActivator ( PyObject *  self)
static

Implements Atrinik.WhoIsActivator() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1058 of file plugin_python.c.

static PyObject* Atrinik_WhoIsOther ( PyObject *  self)
static

Implements Atrinik.WhoIsOther() Python method.

Parameters
selfSelf object for methods; module object for module functions.

Definition at line 1082 of file plugin_python.c.

static void command_custom_python ( object op,
const char *  command,
char *  params 
)
static

Format for a command handler function.

Parameters
opThe player.
commandThe command's name.
paramsOptional arguments for the command.

Definition at line 874 of file plugin_python.c.

static PyCodeObject* compilePython ( char *  filename)
static

Outputs the compiled bytecode for a given python file, using in-memory caching of bytecode.

Definition at line 665 of file plugin_python.c.

static void freeContext ( PythonContext context)
static

Free a context.

Parameters
contextContext to free.

Definition at line 553 of file plugin_python.c.

PyObject* generic_field_getter ( fields_struct field,
void *  ptr 
)

A generic field getter for all interfaces.

Parameters
typeType of the field.
field_ptrField pointer.
field_ptr2Field pointer for extra data.
Returns
Python object containing value of field_ptr (and field_ptr2, if applicable).

Definition at line 3126 of file plugin_python.c.

int generic_field_setter ( fields_struct field,
void *  ptr,
PyObject *  value 
)

A generic field setter for all interfaces.

Parameters
typeType of the field.
[out]field_ptrField pointer.
valueValue to set for the field pointer.
Returns
0 on success, -1 on failure.

Definition at line 2688 of file plugin_python.c.

PyObject* generic_rich_compare ( int  op,
int  result 
)

Generic rich comparison function.

Parameters
op
result
Returns

Definition at line 3263 of file plugin_python.c.

static int handle_event ( va_list  args)
static

Handles normal events.

Parameters
argsList of arguments for context.
Returns
0 on failure, script's return value otherwise.

Definition at line 2100 of file plugin_python.c.

static int handle_global_event ( int  event_type,
va_list  args 
)
static

Handles global event.

Parameters
event_typeThe event ID.
argsList of arguments for context.
Returns
0.

Definition at line 2175 of file plugin_python.c.

static int handle_map_event ( va_list  args)
static

Handles map events.

Parameters
argsList of arguments for context.
Returns
0 on failure, script's return value otherwise.

Definition at line 2139 of file plugin_python.c.

static int handle_unit_event ( va_list  args)
static

Handles unit test event.

Parameters
argsList of arguments for context.
Returns
0.

Definition at line 2310 of file plugin_python.c.

static void initContextStack ( void  )
static

Initialize the context stack.

Definition at line 505 of file plugin_python.c.

static void module_add_array ( PyObject *  module,
const char *  name,
void *  array,
size_t  array_size,
field_type  type 
)
static

Construct a list from C array and add it to the specified module.

Parameters
moduleModule to add to.
nameName of the list.
arrayPointer to the C array.
array_sizeNumber of entries in the C array.
typeType of the entries in the C array.

Definition at line 2494 of file plugin_python.c.

static void module_add_constants ( PyObject *  module,
const char *  name,
const Atrinik_Constant consts,
const char *  doc 
)
static

Creates a new module containing integer constants, and adds it to the specified module.

Parameters
moduleModule to add to.
nameName of the created module.
constantsConstants to add.
docDocstring for the created module.

Definition at line 2464 of file plugin_python.c.

static PyObject* module_create ( PyObject *  parent,
const char *  name 
)
static

Create a module.

Parameters
parentParent module.
nameName of the module.
Returns
The new module created using PyModule_New().

Definition at line 2443 of file plugin_python.c.

static PythonContext* popContext ( void  )
static

Pop the first context from the current context, replacing it by the next one in the list.

Returns
NULL if there is no current context, the previous current context otherwise.

Definition at line 535 of file plugin_python.c.

static void pushContext ( PythonContext context)
static

Push context to the context stack and to current context.

Parameters
contextThe context to push.

Definition at line 516 of file plugin_python.c.

static PyObject* py_runfile ( const char *  path,
PyObject *  globals,
PyObject *  locals 
)
static

Run a Python file. 'path' is automatically resolved to the current maps directory.

Parameters
pathThe Python file in the maps directory to run (absolute).
globalsGlobals dictionary.
localsLocals dictionary. May be NULL.
Returns
The returned object, if any.

Definition at line 570 of file plugin_python.c.

static void py_runfile_simple ( const char *  path,
PyObject *  locals 
)
static

Simplified interface to py_runfile(); automatically constructs the globals dictionary with the Python builtins.

Parameters
pathThe Python file in the maps directory to run (absolute).
localsLocals dictionary. May be NULL.

Definition at line 613 of file plugin_python.c.

static void PyErr_LOG ( void  )
static

Log a Python exception. Will also send the exception to any online DMs or those with /resetmap command permission.

Definition at line 632 of file plugin_python.c.

int python_call_int ( PyObject *  callable,
PyObject *  arglist 
)

Call a function defined in Python script with the specified arguments.

Parameters
callableWhat to call.
arglistArguments to call the function with. Will have reference decreased.
Returns
Integer value the function returned.

Definition at line 3301 of file plugin_python.c.

static int set_animation_field ( void *  ptr,
long  anim_id 
)
static

Sets animation field.

Parameters
ptrPointer to ::uint16 structure member.
anim_idID of the animation to set.
Returns
0 on success, -1 on failure.

Definition at line 2666 of file plugin_python.c.

static int set_face_field ( void *  ptr,
long  face_id 
)
static

Sets face field.

Parameters
ptrPointer to New_Face structure.
face_idID of the face to set.
Returns
0 on success, -1 on failure.

Definition at line 2645 of file plugin_python.c.

Variable Documentation

PyObject* AtrinikError

A generic exception that we use for error messages.

Definition at line 55 of file plugin_python.c.

PyMethodDef AtrinikMethods[]
static

Here is the Python Declaration Table, used by the interpreter to make an interface with the C code.

Definition at line 2022 of file plugin_python.c.

const Atrinik_Constant constants[]
static

Useful constants

Definition at line 103 of file plugin_python.c.

const char* const constants_colors[][2]
static
Initial value:
= {
{"COLOR_WHITE", COLOR_WHITE},
{"COLOR_ORANGE", COLOR_ORANGE},
{"COLOR_NAVY", COLOR_NAVY},
{"COLOR_RED", COLOR_RED},
{"COLOR_GREEN", COLOR_GREEN},
{"COLOR_BLUE", COLOR_BLUE},
{"COLOR_GRAY", COLOR_GRAY},
{"COLOR_BROWN", COLOR_BROWN},
{"COLOR_PURPLE", COLOR_PURPLE},
{"COLOR_PINK", COLOR_PINK},
{"COLOR_YELLOW", COLOR_YELLOW},
{"COLOR_DK_NAVY", COLOR_DK_NAVY},
{"COLOR_DK_GREEN", COLOR_DK_GREEN},
{"COLOR_DK_ORANGE", COLOR_DK_ORANGE},
{"COLOR_HGOLD", COLOR_HGOLD},
{"COLOR_DGOLD", COLOR_DGOLD},
{NULL, NULL}
}

Color constants

Definition at line 479 of file plugin_python.c.

const Atrinik_Constant constants_gender[]
static
Initial value:
= {
{"NEUTER", GENDER_NEUTER},
{"MALE", GENDER_MALE},
{"FEMALE", GENDER_FEMALE},
{"HERMAPHRODITE", GENDER_HERMAPHRODITE},
{NULL, 0}
}
#define GENDER_MALE
Definition: object.h:633
#define GENDER_HERMAPHRODITE
Definition: object.h:637
#define GENDER_NEUTER
Definition: object.h:631
#define GENDER_FEMALE
Definition: object.h:635

Gender constants.

Definition at line 467 of file plugin_python.c.

const Atrinik_Constant constants_types[]
static

Game object type constants.

Definition at line 357 of file plugin_python.c.

PythonContext* context_stack
static

The context stack.

Definition at line 58 of file plugin_python.c.

PythonContext* current_context

Current context.

Definition at line 60 of file plugin_python.c.

const char doc_Atrinik_CacheAdd[]
static
Initial value:
=
".. function:: CacheAdd(key, what).\n\n"
"Store 'what' in memory identified by unique identifier 'key'.\n\n"
"The object will be stored forever in memory, until it's either removed by "
":func:`~Atrinik.CacheRemove` or the server is shut down; in both cases, the "
"object will be closed, if applicable (databases, file objects, etc)\n\n."
"A stored object can be retrieved at any time using :func:"
"`~Atrinik.CacheGet`.\n\n"
":param key: The unique identifier for the cache entry.\n"
":type key: str\n"
":param what: Any Python object (string, integer, database, etc) to store in "
"memory.\n"
":type what: object\n"
":returns: True if the object was cached successfully, False otherwise (cache "
"entry with same key name already exists).\n"
":rtype: bool"

Documentation for Atrinik_CacheAdd().

Definition at line 1532 of file plugin_python.c.

const char doc_Atrinik_CacheGet[]
static
Initial value:
=
".. function:: CacheGet(key).\n\n"
"Attempt to find a cache entry identified by 'key' that was previously added "
"using :func:`~Atrinik.CacheAdd`.\n\n"
":param key: Unique identifier of the cache entry to find.\n"
":type key: str\n"
":returns: The cache entry.\n"
":rtype: object\n"
":raises ValueError: If the cache entry could not be found."

Documentation for Atrinik_CacheGet().

Definition at line 1572 of file plugin_python.c.

const char doc_Atrinik_CacheRemove[]
static
Initial value:
=
".. function:: CacheRemove(key).\n\n"
"Remove a cache entry that was added with a previous call to :func:"
"`~Atrinik.CacheAdd`.\n\n"
":param key: Unique identifier of the cache entry to remove.\n"
":type key: str\n"
":returns: True is always returned.\n"
":rtype: bool\n"
":raises ValueError: If the cache entry could not be removed (it didn't exist)"

Documentation for Atrinik_CacheRemove().

Definition at line 1619 of file plugin_python.c.

const char doc_Atrinik_CostString[]
static
Initial value:
=
".. function:: CostString(value).\n\n"
"Build a string representation of the value in the game's money syntax, for "
"example, a value of 134 would become \"1 silver coin and 34 copper "
"coins\".\n\n"
":param value: Value to build the string from.\n"
":type value: int\n"
":returns: The string.\n"
":rtype: str"

Documentation for Atrinik_CostString().

Definition at line 1506 of file plugin_python.c.

const char doc_Atrinik_CreateMap[]
static
Initial value:
=
".. function:: CreateMap(width, height, path).\n\n"
"Creates an empty map.\n\n"
":param width: The new map's width.\n"
":type width: int\n"
":param height: The new map's height.\n"
":type height: int\n"
":param path: Path to the new map. This should be a unique path to avoid "
"collisions. \"/python-maps/\" is prepended to this to ensure no collision "
"with regular maps.\n"
":type path: str\n"
":returns: The new empty map.\n"
":rtype: :class:`Atrinik.Map.Map`"

Documentation for Atrinik_CreateMap().

Definition at line 1701 of file plugin_python.c.

const char doc_Atrinik_CreateObject[]
static
Initial value:
=
".. function:: CreateObject(archname).\n\n"
"Creates a new object. Note that if the created object is not put on map or "
"inside an inventory of another object, it will be considered a leaked object. "
"Use :meth:`Atrinik.Object.Object.Destroy` to free it if you no longer need "
"it.\n\n"
":param archname: Name of the arch to create.\n"
":type archname: str\n"
":returns: The newly created object.\n"
":rtype: :class:`Atrinik.Object.Object`\n"
":raises Atrinik.AtrinikError: If *archname* is not a valid archetype."

Documentation for Atrinik_CreateObject().

Definition at line 1737 of file plugin_python.c.

const char doc_Atrinik_CreatePathname[]
static
Initial value:
=
".. function:: CreatePathname(path).\n\n"
"Creates path to a file in the maps directory. For example, '/hall_of_dms' -> "
"'../maps/hall_of_dms'.\n\n"
":param path: Path to the map.\n"
":type path: str\n"
":returns: Real path of the map on the system.\n"
":rtype: str"

Documentation for Atrinik_CreatePathname().

Definition at line 1310 of file plugin_python.c.

const char doc_Atrinik_Eval[]
static
Initial value:
=
".. function:: Eval(code, seconds=0.0).\n\n"
"Executes the specified code from the main thread after the specified delay in "
"seconds.\n\n"
":param code: The code to compile and execute.\n"
":type code: str\n"
":param seconds: How long to wait, eg, 0.5 for half a second, 10.0 for 10 "
"seconds, etc.\n"
":type seconds: float"

Documentation for Atrinik_Eval().

Definition at line 1857 of file plugin_python.c.

const char doc_Atrinik_FindParty[]
static
Initial value:
=
".. function:: FindParty(name).\n\n"
"Find a party by name.\n\n"
":param name: The party name to find.\n"
":type name: str\n"
":returns: The party if found, None otherwise.\n"
":rtype: :class:`Atrinik.Party.Party` or None"

Documentation for Atrinik_FindParty().

Definition at line 1393 of file plugin_python.c.

const char doc_Atrinik_FindPlayer[]
static
Initial value:
=
".. function:: FindPlayer(name).\n\n"
"Find a player by name.\n\n"
":param name: The player name to find.\n"
":type name: str\n"
":returns: The player's object if found, None otherwise.\n"
":rtype: :class:`Atrinik.Object.Object` or None"

Documentation for Atrinik_FindPlayer().

Definition at line 963 of file plugin_python.c.

const char doc_Atrinik_GetArchetype[]
static
Initial value:
=
".. function:: GetArchetype(archname).\n\n"
"Finds an archetype.\n\n"
":param archname: Name of the archetype to find.\n"
":type archname: str\n"
":returns: The archetype.\n"
":rtype: :class:`Atrinik.Archetype.Archetype`\n"
":raises Atrinik.AtrinikError: If *archname* is not a valid archetype."

Documentation for Atrinik_GetArchetype().

Definition at line 1788 of file plugin_python.c.

const char doc_Atrinik_GetEventNumber[]
static
Initial value:
=
".. function:: GetEventNumber().\n\n"
"Get the ID of the event that is being triggered.\n\n"
":returns: Event ID.\n"
":rtype: int\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread).\n"
":raises Atrinik.AtrinikError: If there is no event object."

Documentation for Atrinik_GetEventNumber().

Definition at line 1116 of file plugin_python.c.

const char doc_Atrinik_GetEventParameters[]
static
Initial value:
=
".. function:: GetEventParameters().\n\n"
"Get the parameters of an event. This varies from event to event, and some "
"events pass all parameters as 0. EVENT_ATTACK usually passes damage done and "
"the WC of the hit as second and third parameter, respectively.\n\n"
":returns: A list of the event parameters. The last entry is the event flags, "
"used to determine whom to call :meth:`Atrinik.Object.Object.Update` on after "
"executing the script.\n"
":rtype: list\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread)."

Documentation for Atrinik_GetEventParameters().

Definition at line 1246 of file plugin_python.c.

const char doc_Atrinik_GetFirst[]
static
Initial value:
=
".. function:: GetFirst(what).\n\n"
"Get first member of various linked lists.\n\n"
":param what: What list to get first member of. Available list names:\n\n"
" * player: First player.\n"
" * map: First map.\n"
" * archetype: First archetype.\n"
" * party: First party.\n"
" * region: First region.\n"
":type what: str\n"
":returns: First member of the specified linked list.\n"
":rtype: :class:`Atrinik.Player.Player` or :class:`Atrinik.Map.Map` or "
":class:`Atrinik.Party.Party` or :class:`Atrinik.Region.Region`\n"
":raises ValueError: If *what* is invalid."

Documentation for Atrinik_GetFirst().

Definition at line 1659 of file plugin_python.c.

const char doc_Atrinik_GetOptions[]
static
Initial value:
=
".. function:: GetOptions().\n\n"
"Gets the script options (as passed in the event's slaying field).\n\n"
":returns: The script options.\n"
":rtype: str or None\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread)."

Documentation for Atrinik_GetOptions().

Definition at line 1168 of file plugin_python.c.

const char doc_Atrinik_GetRangeVectorFromMapCoords[]
static
Initial value:
=
".. function:: GetRangeVectorFromMapCoords(map1, x1, y1, map2, x2, y2, "
"flags=0).\n\n"
"Get the distance and direction from one map coordinate to another.\n\n"
":param map1: From which map to get the distance from.\n"
":type map1: :class:`Atrinik.Map.Map`\n"
":param x1: X coordinate on *map1*.\n"
":type x1: int\n"
":param y1: Y coordinate on *map1*.\n"
":type y1: int\n"
":param map2: From which map to get the distance to.\n"
":type map2: :class:`Atrinik.Map.Map`\n"
":param x2: X coordinate on *map2*.\n"
":type x2: int\n"
":param y2: Y coordinate on *map2*.\n"
":type y2: int\n"
":param flags: One or a combination of RV_xxx, eg, :attr:"
"`~Atrinik.RV_MANHATTAN_DISTANCE`\n"
":type flags: int\n"
":returns: None if the distance couldn't be calculated, otherwise a "
"tuple containing:\n\n"
" * Direction from the first coordinate to the second, eg, :attr:\n"
" `~Atrinik.NORTH`\n"
" * Distance between the two coordinates.\n"
" * X distance.\n"
" * Y distance.\n"
":rtype: tuple or None"

Documentation for Atrinik_GetRangeVectorFromMapCoords().

Definition at line 1446 of file plugin_python.c.

const char doc_Atrinik_GetReturnValue[]
static
Initial value:
=
".. function:: GetReturnValue().\n\n"
"Gets the script's return value.\n\n"
":returns: The return value.\n"
":rtype: int\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread)."

Documentation for Atrinik_GetReturnValue().

Definition at line 1191 of file plugin_python.c.

const char doc_Atrinik_GetSettings[]
static
Initial value:
=
".. function:: GetSettings().\n\n"
"Acquire a dictionary containing the server's settings.\n\n"
":returns: Dictionary with the server's settings, such as the maps path.\n"
":rtype: dict"

Documentation for Atrinik_GetSettings().

Definition at line 1920 of file plugin_python.c.

const char doc_Atrinik_GetTicks[]
static
Initial value:
=
".. function:: GetTicks().\n\n"
"Acquires the current server ticks value.\n\n"
":returns: The server ticks.\n"
":rtype: int"

Documentation for Atrinik_GetTicks().

Definition at line 1772 of file plugin_python.c.

const char doc_Atrinik_GetTime[]
static
Initial value:
=
".. function:: GetTime().\n\n"
"Get the game time.\n\n"
":returns: A dictionary containing all the information about the in-game "
"time:\n\n"
" * **year**: Current year.\n"
" * **month**: Current month.\n"
" * **month_name**: Name of the current month.\n"
" * **day**: Day.\n"
" * **hour**: Hour.\n"
" * **minute**: Minute.\n"
" * **dayofweek**: Day of the week.\n"
" * **dayofweek_name**: Name of the week day.\n"
" * **season**: Season.\n"
" * **season_name**: Name of the season.\n"
" * **periodofday**: Period of the day.\n"
" * **periodofday_name**: Name of the period of the day.\n"
":rtype: dict"

Documentation for Atrinik_GetTime().

Definition at line 1335 of file plugin_python.c.

const char doc_Atrinik_LoadObject[]
static
Initial value:
=
".. function:: LoadObject(text).\n\n"
"Load an object from a string dump, for example, one stored using "
":meth:`Atrinik.Object.Object.Save`.\n\n"
":param text: The object text dump.\n"
":type text: str\n"
":returns: New object, loaded from the text or None in case of failure.\n"
":rtype: :class:`Atrinik.Object.Object` or None"

Documentation for Atrinik_LoadObject().

Definition at line 905 of file plugin_python.c.

const char doc_Atrinik_Logger[]
static
Initial value:
=
".. function:: Logger(level, message).\n\n"
"Logs a message.\n\n"
":param level: Level of the log message, eg, \"BUG\", \"ERROR\", \"CHAT\", "
"\"INFO\", etc.\n"
":type level: str\n"
":param message: The message to log. Cannot contain newlines.\n"
":type message: str"

Documentation for Atrinik_Logger().

Definition at line 1417 of file plugin_python.c.

const char doc_Atrinik_PlayerExists[]
static
Initial value:
=
".. function:: PlayerExists(name).\n\n"
"Check if player exists.\n\n"
":param name: The player name to check.\n"
":type name: str\n"
":returns: True if the player exists, False otherwise.\n"
":rtype: bool"

Documentation for Atrinik_PlayerExists().

Definition at line 993 of file plugin_python.c.

const char doc_Atrinik_print[]
static
Initial value:
=
".. function:: print(...).\n\n"
"Prints the string representations of the given objects to the server log, as "
"well as all online DMs. Essentially a replacement for standard library "
"print() function.\n\n"

Documentation for Atrinik_print().

Definition at line 1820 of file plugin_python.c.

const char doc_Atrinik_Process[]
static
Initial value:
=
".. function:: Process().\n\n"
"Simulates server processing.\n\n"
":raises Atrinik.AtrinikError: If called outside the plugin unit tests."

Documentation for Atrinik_Process().

Definition at line 1995 of file plugin_python.c.

const char doc_Atrinik_ReadyMap[]
static
Initial value:
=
".. function:: ReadyMap(path, unique=False).\n\n"
"Make sure the named map is loaded into memory, loading it if necessary.\n\n"
":param path: Path to the map.\n"
":type path: str\n"
":param unique: Whether the destination should be loaded as a unique map, for "
"example, apartments.\n"
":type unique: bool\n"
":returns: The map associated with the specified path or None in case of "
"failure.\n"
":rtype: :class:`Atrinik.Map.Map` or None"

Documentation for Atrinik_ReadyMap().

Definition at line 930 of file plugin_python.c.

const char doc_Atrinik_RegisterCommand[]
static
Initial value:
=
".. function:: RegisterCommand(name, speed, flags=0).\n\n"
"Register a custom command ran using Python script.\n\n"
":param name: Name of the command. For example, \"roll\" in order to create "
"/roll command. Note the lack of forward slash in the name.\n"
":type name: str\n"
":param speed: How long it takes to execute the command; 1.0 is usually fine.\n"
":type speed: float\n"
":param flags: Optional flags.\n"
":type flags: int"

Documentation for Atrinik_RegisterCommand().

Definition at line 1278 of file plugin_python.c.

const char doc_Atrinik_SetReturnValue[]
static
Initial value:
=
".. function:: SetReturnValue(value).\n\n"
"Sets the script's return value.\n\n"
":param value: The new return value.\n"
":type value: int\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread)."

Documentation for Atrinik_SetReturnValue().

Definition at line 1214 of file plugin_python.c.

const char doc_Atrinik_WhatIsEvent[]
static
Initial value:
=
".. function:: WhatIsEvent().\n\n"
"Get the event object that caused this event to trigger.\n\n"
":returns: The event object.\n"
":rtype: :class:`Atrinik.Object.Object` or None\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread)."

Documentation for Atrinik_WhatIsEvent().

Definition at line 1093 of file plugin_python.c.

const char doc_Atrinik_WhatIsMessage[]
static
Initial value:
=
".. function:: WhatIsMessage().\n\n"
"Gets the actual message in SAY events.\n\n"
":returns: The message.\n"
":rtype: str or None\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread)."

Documentation for Atrinik_WhatIsMessage().

Definition at line 1145 of file plugin_python.c.

const char doc_Atrinik_WhoAmI[]
static
Initial value:
=
".. function:: WhoAmI().\n\n"
"Get the owner of the active script (the object that has the event "
"handler).\n\n"
":returns: The script owner.\n"
":rtype: :class:`Atrinik.Object.Object` or None\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread)."

Documentation for Atrinik_WhoAmI().

Definition at line 1022 of file plugin_python.c.

const char doc_Atrinik_WhoIsActivator[]
static
Initial value:
=
".. function:: WhoIsActivator().\n\n"
"Get the object that activated the current event.\n\n"
":returns: The script activator.\n"
":rtype: :class:`Atrinik.Object.Object` or None\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread)."

Documentation for Atrinik_WhoIsActivator().

Definition at line 1046 of file plugin_python.c.

const char doc_Atrinik_WhoIsOther[]
static
Initial value:
=
".. function:: WhoIsOther().\n\n"
"Get another object related to the event. What this object is depends on the "
"event.\n\n"
":returns: The other object.\n"
":rtype: :class:`Atrinik.Object.Object` or None\n"
":raises Atrinik.AtrinikError: If there's no event context (for example, the "
"script is running in a thread)."

Documentation for Atrinik_WhoIsOther().

Definition at line 1069 of file plugin_python.c.

const char module_doc_gender[]
static
Initial value:
=
"Contains gender related constants."

The Atrinik Gender module docstring.

Definition at line 97 of file plugin_python.c.

const char module_doc_type[]
static
Initial value:
=
"Contains all the Atrinik object types as constants."

The Atrinik Type module docstring.

Definition at line 93 of file plugin_python.c.

const char package_doc[]
static
Initial value:
=
"The Atrinik Python package provides an interface to the Atrinik server.\n\n"
"The server is able to run Python scripts dynamically, usually as a response "
"to some event."

The Atrinik package docstring.

Definition at line 87 of file plugin_python.c.

PyObject* py_globals_dict = NULL
static

The global variables dictionary.

Definition at line 64 of file plugin_python.c.

python_cache_entry* python_cache = NULL
static

The Python cache.

Definition at line 500 of file plugin_python.c.

python_eval_struct* python_eval
static

The first code to evaluate.

Definition at line 84 of file plugin_python.c.