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)[源代码]

基类:object

Implements the handler. This sits on each game object.

__init__(obj)[源代码]

Set up internal state.

参数

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

add(scriptclass, key=None, autostart=True)[源代码]

Add a script to this object.

参数
  • 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.

返回

Script – The newly created Script.

start(key)[源代码]

Find scripts and force-start them

参数

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

返回

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

has(key)[源代码]

Determine if a given script exists on this object.

参数

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

返回

bool – If the script exists or not.

get(key)[源代码]

Search scripts on this object.

参数

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

返回

scripts (queryset) – The found scripts matching key.

remove(key=None)[源代码]

Forcibly delete a script from this object.

参数

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.

参数

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.

参数

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()[源代码]

Get all scripts stored in this handler.