Skip to content

function callEvent

This function will notify (call) every handler bound to specified event.
Original: callEvent

Declaration

def callEvent(evtName : str, **kwargs : list)

Parameters

  • str name: the name of the event
  • **dict kwargs: the variable number of arguments.

Usage

import g2o

g2o.addEvent('testEvt')

@g2o.event('testEvt')
def onTestEvent(**kwargs):
    print(f'{kwargs['name']} called my beautiful test event')

g2o.callEvent('testEvt', name = 'Diego')
Source code in src/pyg2o/functions/event.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
async def callEvent(evtName : str, **kwargs : list):
    """
    This function will notify (call) every handler bound to specified event.
    Original: [callEvent](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/shared-functions/event/callEvent/)

    ## Declaration
    ```python
    def callEvent(evtName : str, **kwargs : list)
    ```

    ## Parameters
    * `str` **name**: the name of the event
    * `**dict` **kwargs**: the variable number of arguments.

    ## Usage
    ```python
    import g2o

    g2o.addEvent('testEvt')

    @g2o.event('testEvt')
    def onTestEvent(**kwargs):
        print(f'{kwargs['name']} called my beautiful test event')

    g2o.callEvent('testEvt', name = 'Diego')
    ```
    """

    if evtName in eventList and evtName not in disabledEventList:
        for event in eventList[evtName]:

            event['function'].eventName = evtName
            result = await event['function'](**kwargs)