π¦ JEEventWatcher
Technical reference for the
JEEventWatcherclass 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)