πŸ“¦ JEEventWatcher

Technical reference for the JEEventWatcher class of JarEngine.

Inherit from β€’>JEInternBaseClass<β€’πŸ“Ž


πŸ”Ή Overview

JEEventWatcher is responsible for monitoring general events and executing actions when matching event codes are detected.

Provides:

  • Event matching through event codes and groups.
  • Automatic callback execution when a matching event occurs.
  • Access to watcher configuration and callback information.

Represents a generic event watcher used by JarEngine’s event system. It links one or multiple event codes to a callback function, allowing games to react to custom events without manually filtering every received event.


πŸ”Ή Location

JarEngine
β”‚
β”œβ”€β”€ events
β”‚     └── JEEventWatcher
β”‚
└── ...

πŸ”Ή Data

Field Type Description Property? Can be set?
on JEEventCodeGroup Event codes monitored by the watcher. True False
do str String representation of the callback function. True False

πŸ”Ή API

Function Arguments Returns Description
__init__ on: JEEventCode \| list[JEEventCode] \| JEEventCodeGroup, do: Callable[[JEGame, JEEvent], None] Β  Creates an event watcher linked to one or multiple event codes and a callback function.
match event: JEEvent bool Checks if an event matches the watched event codes.
__call__ game: JEGame, event: JEEvent Β  Executes the callback function associated with the watcher.

πŸ”Ή Usage

from jarengine import Events
from jarengine import Games

game = Games.JEGame()

def on_event(game, event):
    print("Event received")

watcher = Events.Event.JEEventWatcher(
    Events.Event.JEEventCode(1),
    on_event
)

game.event.add(watcher)