asobi_lua_match_shared (asobi v0.72.5)

View Source

Variant of asobi_lua_match for matches where every player sees the same world state. The match server calls get_state/1 once per tick and encodes the result once for the whole roster, instead of re-encoding once per player. asobi_presence:send_match_state/3 then hands each connected session that one binary and each bot the payload behind it as a term.

Selected by declaring state_strategy = "shared" in the match script's config globals. The Lua script must define get_state(state) (one argument). All other callbacks are identical to asobi_lua_match and are delegated to it directly.

Summary

Functions

get_state/1

-spec get_state(map()) -> map().

handle_input(PlayerId, Input, State)

-spec handle_input(binary(), map(), map()) -> {ok, map()}.

init(Config)

-spec init(map()) -> {ok, map()}.

join(PlayerId, State)

-spec join(binary(), map()) -> {ok, map()} | {error, term()}.

join(PlayerId, Ctx, State)

-spec join(binary(), map(), map()) -> {ok, map()} | {error, term()}.

leave(PlayerId, State)

-spec leave(binary(), map()) -> {ok, map()}.

tick(State)

-spec tick(map()) -> {ok, map()} | {finished, map(), map()}.

vote_requested(State)

-spec vote_requested(map()) -> {ok, map()} | none.

vote_resolved(Template, Result, State)

-spec vote_resolved(binary(), map(), map()) -> {ok, map()}.