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:
objectImplements 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.
- Returns:
Script – The newly created Script.
- 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.
- has(key)[source]¶
Determine if a given script exists on this object.
- Parameters:
key (str) – Search criterion, the script’s key or dbref.
- Returns:
bool – If the script exists or not.
- get(key)[source]¶
Search scripts on this object.
- Parameters:
key (str) – Search criterion, the script’s key or dbref.
- Returns:
scripts (queryset) – The found scripts matching key.
- remove(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!
- delete(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!
- 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!