evennia.scripts.manager¶
The custom manager for Scripts.
-
class
evennia.scripts.manager.
ScriptManager
(*args, **kwargs)[源代码]¶ 基类:
evennia.scripts.manager.ScriptDBManager
,evennia.typeclasses.managers.TypeclassManager
-
class
evennia.scripts.manager.
ScriptDBManager
(*args, **kwargs)[源代码]¶ 基类:
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) 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)[源代码]¶ Find all Scripts related to a particular object.
- 参数
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.
- 返回
matches (list) – Matching scripts.
-
get_all_scripts
(key=None)[源代码]¶ Get all scripts in the database.
- 参数
key (str or int, optional) – Restrict result to only those with matching key or dbref.
- 返回
scripts (list) – All scripts found, or those matching key.
-
delete_script
(dbref)[源代码]¶ This stops and deletes a specific script directly from the script database.
- 参数
dbref (int) – Database unique id.
提示
This might be needed for global scripts not tied to a specific game object
-
update_scripts_after_server_start
()[源代码]¶ Update/sync/restart/delete scripts after server shutdown/restart.
-
search_script
(ostring, obj=None, only_timed=False, typeclass=None)[源代码]¶ Search for a particular script.
- 参数
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.
- 返回
Queryset – An iterable with 0, 1 or more results.
-
script_search
(ostring, obj=None, only_timed=False, typeclass=None)¶ Search for a particular script.
- 参数
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.
- 返回
Queryset – An iterable with 0, 1 or more results.
-
copy_script
(original_script, new_key=None, new_obj=None, new_locks=None)[源代码]¶ Make an identical copy of the original_script.
- 参数
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.
- 返回
script_copy (Script) –
- A new Script instance, copied from
the original.
-
create_script
(typeclass=None, key=None, obj=None, account=None, locks=None, interval=None, start_delay=None, repeats=None, persistent=None, autostart=True, report_to=None, desc=None, tags=None, attributes=None)[源代码]¶ Create a new script. All scripts are a combination of a database object that communicates with the database, and an typeclass that ‘decorates’ the database object into being different types of scripts. It’s behaviour is similar to the game objects except scripts has a time component and are more limited in scope.
- 关键字参数
typeclass (class or str) – Class or python path to a typeclass.
key (str) – Name of the new object. If not set, a name of #dbref will be set.
obj (Object) – The entity on which this Script sits. If this is None, we are creating a “global” script.
account (Account) – The account on which this Script sits. It is exclusiv to obj.
locks (str) – one or more lockstrings, separated by semicolons.
interval (int) – The triggering interval for this Script, in seconds. If unset, the Script will not have a timing component.
start_delay (bool) – If True, will wait interval seconds before triggering the first time.
repeats (int) – The number of times to trigger before stopping. If unset, will repeat indefinitely.
persistent (bool) – If this Script survives a server shutdown or not (all Scripts will survive a reload).
autostart (bool) – If this Script will start immediately when created or if the start method must be called explicitly.
report_to (Object) – The object to return error messages to.
desc (str) – Optional description of script
tags (list) – List of tags or tuples (tag, category).
attributes (list) – List if tuples (key, value) or (key, value, category) (key, value, lockstring) or (key, value, lockstring, default_access).
- 返回
script (obj) – An instance of the script created
See evennia.scripts.manager for methods to manipulate existing scripts in the database.
-