# 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.

  Parameters

    path_or_typeclass (str or type) – the Python path leading to the class containing events, or the class itself.

  Returns

    The typeclass itself.

  Notes

  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.

  Parameters

    format (str) – a time format matching the set calendar.

  Returns

    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.

  Notes

  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.

  Parameters

    - 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…).

  Parameters

    - callbacks (list of dict) – the list of callbacks to be called.

    - parameters (str) – the actual parameters entered to trigger the callback.

  Returns

    A list containing the callback dictionaries to be called.

  Notes

  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).

  Parameters

    - callbacks (list of dict) – the list of callbacks to be called.

    - parameters (str) – the actual parameters entered to trigger the callback.

  Returns

    A list containing the callback dictionaries to be called.

  Notes

  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’).

exception `evennia.contrib.base_systems.ingame_python.utils.``InterruptEvent`

  Bases: `RuntimeError`

  Interrupt the current event.

  You shouldn’t have to use this exception directly, probably use the deny() function that handles it instead.