evennia.scripts.scripthandler

The script handler makes sure to check through all stored scripts to make sure they are still relevant. A scripthandler is automatically added to all game objects. You access it through the property scripts on the game object.

class evennia.scripts.scripthandler.ScriptHandler(obj)[source]

Bases: object

Implements the handler. This sits on each game object.

__init__(obj)[source]

Set up internal state.

Parameters

obj (Object) – A reference to the object this handler is attached to.

add(scriptclass, key=None, autostart=True)[source]

Add a script to this object.

Parameters
  • scriptclass (Scriptclass, Script or str) – Either a class object inheriting from DefaultScript, an instantiated script object or a python path to such a class object.

  • key (str, optional) – Identifier for the script (often set in script definition and listings)

  • autostart (bool, optional) – Start the script upon adding it.

start(key)[source]

Find scripts and force-start them

Parameters

key (str) – The script’s key or dbref.

Returns

nr_started (int) – The number of started scripts found.

get(key)[source]

Search scripts on this object.

Parameters

key (str) – Search criterion, the script’s key or dbref.

Returns

scripts (list) – The found scripts matching key.

delete(key=None)[source]

Forcibly delete a script from this object.

Parameters

key (str, optional) – A script key or the path to a script (in the latter case all scripts with this path will be deleted!) If no key is given, delete all scripts on the object!

stop(key=None)

Forcibly delete a script from this object.

Parameters

key (str, optional) – A script key or the path to a script (in the latter case all scripts with this path will be deleted!) If no key is given, delete all scripts on the object!

all()[source]

Get all scripts stored in this handler.