evennia.scripts.manager

The custom manager for Scripts.

class evennia.scripts.manager.ScriptManager(*args, **kwargs)[source]

Bases: evennia.scripts.manager.ScriptDBManager, evennia.typeclasses.managers.TypeclassManager

class evennia.scripts.manager.ScriptDBManager(*args, **kwargs)[source]

Bases: evennia.typeclasses.managers.TypedObjectManager

This Scriptmanager implements methods for searching and manipulating Scripts directly from the database.

Evennia-specific search methods (will return Typeclasses or lists of Typeclasses, whereas Django-general methods will return Querysets or database objects).

dbref (converter) get_id (or dbref_search) get_dbref_range object_totals typeclass_search get_all_scripts_on_obj get_all_scripts delete_script remove_non_persistent validate script_search (equivalent to evennia.search_script) copy_script

get_all_scripts_on_obj(obj, key=None)[source]

Find all Scripts related to a particular object.

Parameters
  • obj (Object) – Object whose Scripts we are looking for.

  • key (str, optional) – Script identifier - can be given as a dbref or name string. If given, only scripts matching the key on the object will be returned.

Returns

matches (list) – Matching scripts.

get_all_scripts(key=None)[source]

Get all scripts in the database.

Parameters

key (str or int, optional) – Restrict result to only those with matching key or dbref.

Returns

scripts (list) – All scripts found, or those matching key.

delete_script(dbref)[source]

This stops and deletes a specific script directly from the script database.

Parameters

dbref (int) – Database unique id.

Notes

This might be needed for global scripts not tied to a specific game object

remove_non_persistent(obj=None)[source]

This cleans up the script database of all non-persistent scripts. It is called every time the server restarts.

Parameters

obj (Object, optional) – Only remove non-persistent scripts assigned to this object.

validate(scripts=None, obj=None, key=None, dbref=None, init_mode=None)[source]

This will step through the script database and make sure all objects run scripts that are still valid in the context they are in. This is called by the game engine at regular intervals but can also be initiated by player scripts.

Only one of the arguments are supposed to be supplied at a time, since they are exclusive to each other.

Parameters
  • scripts (list, optional) – A list of script objects to validate.

  • obj (Object, optional) – Validate only scripts defined on this object.

  • key (str) – Validate only scripts with this key.

  • dbref (int) – Validate only the single script with this particular id.

  • init_mode (str, optional) – This is used during server upstart and can have three values: - None (no init mode). Called during run. - “reset” - server reboot. Kill non-persistent scripts - “reload” - server reload. Keep non-persistent scripts.

Returns

nr_started, nr_stopped (tuple)

Statistics on how many objects

where started and stopped.

Notes

This method also makes sure start any scripts it validates which should be harmless, since already-active scripts have the property ‘is_running’ set and will be skipped.

search_script(ostring, obj=None, only_timed=False, typeclass=None)[source]

Search for a particular script.

Parameters
  • ostring (str) – Search criterion - a script dbef or key.

  • obj (Object, optional) – Limit search to scripts defined on this object

  • only_timed (bool) – Limit search only to scripts that run on a timer.

  • typeclass (class or str) – Typeclass or path to typeclass.

Search for a particular script.

Parameters
  • ostring (str) – Search criterion - a script dbef or key.

  • obj (Object, optional) – Limit search to scripts defined on this object

  • only_timed (bool) – Limit search only to scripts that run on a timer.

  • typeclass (class or str) – Typeclass or path to typeclass.

copy_script(original_script, new_key=None, new_obj=None, new_locks=None)[source]

Make an identical copy of the original_script.

Parameters
  • original_script (Script) – The Script to copy.

  • new_key (str, optional) – Rename the copy.

  • new_obj (Object, optional) – Place copy on different Object.

  • new_locks (str, optional) – Give copy different locks from the original.

Returns

script_copy (Script)

A new Script instance, copied from

the original.