<spanclass="nb">print</span><spanclass="p">(</span><spanclass="s1">'user ID "</span><spanclass="si">{}</span><spanclass="s1">" was hurt by attacker ID "</span><spanclass="si">{}</span><spanclass="s1">"'</span><spanclass="o">.</span><spanclass="n">format</span><spanclass="p">(</span><spanclass="n">userid</span><spanclass="p">,</span><spanclass="n">attacker</span><spanclass="p">))</span>
</pre></div>
</div>
<p>In order to listen to an event, you have to import the <aclass="reference internal" href="modules/events.html#events.Event" title="events.Event"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">events.Event</span></code></a>
decorator. The decorator requires a name, which is the name of the event you
want to listen to. All event callbacks require exactly one argument, which is
a <aclass="reference internal" href="modules/events.html#events.GameEvent" title="events.GameEvent"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">events.GameEvent</span></code></a> object. This object can be used to access the
specific event variables.</p>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p><aclass="reference internal" href="modules/events.html#events.GameEvent.__getitem__" title="events.GameEvent.__getitem__"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">events.GameEvent.__getitem__()</span></code></a> will raise a <aclass="reference external" href="https://docs.python.org/3.13/library/exceptions.html#KeyError" title="(in Python v3.13)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">KeyError</span></code></a> if you
are trying to access an event variable that doesn’t exist.</p>
</div>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p><aclass="reference internal" href="modules/events.html#events.GameEvent.__getitem__" title="events.GameEvent.__getitem__"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">events.GameEvent.__getitem__()</span></code></a> will return the value in the type
that has been defined in the event resource files.</p>
</div>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>All games provide different events. Some events might exist on all games,
but they can still provide different event variables.</p>
</div>
</section>
<sectionid="printing-event-variables">
<h2>Printing event variables<aclass="headerlink" href="#printing-event-variables" title="Link to this heading">¶</a></h2>
<p>Sometimes you might want to print all event variables and their values.
Fortunately, there is a <aclass="reference internal" href="modules/events.html#events.GameEvent.variables" title="events.GameEvent.variables"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">events.GameEvent.variables</span></code></a> attribute, which
contains all event variables. You can use this little snippet to display them.</p>