asobi_game_modes (asobi v0.72.6)
View SourceGame-mode configuration, and the registry that maps a mode kind to the module that provides it.
A mode declaring module => {lua, "game/match.lua"} needs a scripting runtime
to run it. That runtime lives outside this library (asobi_lua), so the
provider module is registered here at boot rather than named in core - core
depends on no bridge module.
Summary
Functions
Every game-wide chat channel name declared by any configured game mode.
Register Module as the provider for a game-mode kind.
Resolve a mode to the module that runs it, plus the extra game config it needs.
Drop a registration. Mainly for tests; releases register once and keep it.
Build a world server config map from a mode's game_modes config.
Types
Functions
-spec global_chat_channels() -> [binary()].
Every game-wide chat channel name declared by any configured game mode.
#299: global:<Name> is the one channel scheme that outlives a single world,
so the set of legal names cannot come from the joining client. It is the union
of the chat => #{global => [...]} declarations across game_modes, which is
what asobi_chat_acl authorises against.
-spec register_game_mode(game_mode_kind(), module()) -> ok.
Register Module as the provider for a game-mode kind.
Call this once, at application start - a persistent_term write is not a
hot-path operation. asobi_lua registers its bridge modules this way; a release
built without a scripting runtime simply leaves the table empty, and every
{lua, _} mode then fails with {error, lua_runtime_unavailable} rather than
calling a module that is not in the release.
-spec resolve_game_module(binary()) -> {ok, module(), map()} | {error, not_found | lua_runtime_unavailable}.
Resolve a mode to the module that runs it, plus the extra game config it needs.
{error, not_found} means the mode declares no usable module.
{error, lua_runtime_unavailable} means it declares a Lua script but no
runtime registered a provider for that kind - a release built without
asobi_lua. That case used to be an unenforced convention that failed later
and obscurely; it is now a named error at the point of resolution.
-spec unregister_game_mode(game_mode_kind()) -> ok.
Drop a registration. Mainly for tests; releases register once and keep it.
Build a world server config map from a mode's game_modes config.