Listen for game events, add your own, talk to other mods.
Everything that happens in the game reaches mods as an event. A handler is a function that gets one argument,
the event tablee: its fields describe what happened (see the Events page for every event). Some fields are
writable (e.g. e.damage of hit): change them and the game uses your value. Setting e.cancelled = true on a
cancellable event stops what it announces (e.g. a key reaching the game). Handlers run in priority order, then in the
order they were added; later handlers see what earlier ones changed.
Custom events work the same way: events.emit("mymod:boss_spawned", {creature = c}) reaches every mod's
on("mymod:boss_spawned", ...). Prefix custom names with your mod's id.