osrlib.messages
The default English message formatter.
format_message renders any Event
to a plain English line — pure string templating keyed by the event's outcome-bearing
code, no I/O. It is a total function: an event whose code has no template formats to
the code string itself rather than raising, so a transcript stays printable even when
it holds event types this version of the library doesn't recognize.
Templates reference what the event carries: entity IDs, and — where an event resolves one at emission, as the quest and objective events do — an authored display name. A front end or narrator that wants richer prose resolves IDs itself and localizes freely; this formatter exists so a bare kernel transcript is readable without one.
format_message
Format an event as a default English message.
Total: an event whose code has no template formats to the code string itself — never raises — so logs carrying event types this function doesn't recognize stay printable.
An event carrying a non-empty narrative field — the authored beat a gate's
success rides — has that text appended verbatim after the templated line. This
formatter is the library's deterministic renderer, and authored text is shown
exactly as written.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Event
|
The event to format. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The formatted English line, or the event's code when no template exists. |
Examples: