evennia.contrib.base_systems.ingame_python.utils¶
Functions to extend the event system.
These functions are to be used by developers to customize events and callbacks.
-
evennia.contrib.base_systems.ingame_python.utils.
get_event_handler
()[源代码]¶ Return the event handler or None.
-
evennia.contrib.base_systems.ingame_python.utils.
register_events
(path_or_typeclass)[源代码]¶ Register the events in this typeclass.
- 参数
path_or_typeclass (str or type) – the Python path leading to the class containing events, or the class itself.
- 返回
The typeclass itself.
提示
This function will read events from the _events class variable defined in the typeclass given in parameters. It will add the events, either to the script if it exists, or to some temporary storage, waiting for the script to be initialized.
-
evennia.contrib.base_systems.ingame_python.utils.
get_next_wait
(format)[源代码]¶ Get the length of time in seconds before format.
- 参数
format (str) – a time format matching the set calendar.
- 返回
until (int or float) – the number of seconds until the event. usual (int or float): the usual number of seconds between events. format (str): a string format representing the time.
提示
The time format could be something like “2018-01-08 12:00”. The number of units set in the calendar affects the way seconds are calculated.
-
evennia.contrib.base_systems.ingame_python.utils.
time_event
(obj, event_name, number, parameters)[源代码]¶ Create a time-related event.
- 参数
obj (Object) – the object on which sits the event.
event_name (str) – the event’s name.
number (int) – the number of the event.
parameters (str) – the parameter of the event.
-
evennia.contrib.base_systems.ingame_python.utils.
keyword_event
(callbacks, parameters)[源代码]¶ Custom call for events with keywords (like push, or pull, or turn…).
- 参数
callbacks (list of dict) – the list of callbacks to be called.
parameters (str) – the actual parameters entered to trigger the callback.
- 返回
A list containing the callback dictionaries to be called.
提示
This function should be imported and added as a custom_call parameter to add the event when the event supports keywords as parameters. Keywords in parameters are one or more words separated by a comma. For instance, a ‘push 1, one’ callback can be set to trigger when the player ‘push 1’ or ‘push one’.
-
evennia.contrib.base_systems.ingame_python.utils.
phrase_event
(callbacks, parameters)[源代码]¶ Custom call for events with keywords in sentences (like say or whisper).
- 参数
callbacks (list of dict) – the list of callbacks to be called.
parameters (str) – the actual parameters entered to trigger the callback.
- 返回
A list containing the callback dictionaries to be called.
提示
This function should be imported and added as a custom_call parameter to add the event when the event supports keywords in phrases as parameters. Keywords in parameters are one or more words separated by a comma. For instance, a ‘say yes, okay’ callback can be set to trigger when the player says something containing either “yes” or “okay” (maybe ‘say I don’t like it, but okay’).