QuakeServer.Autocvars (quake_server v0.1.0)

Copy Markdown View Source

A program's autocvar_<name> globals kept equal to console variable <name>, and a server's info keys kept equal to its :serverinfo and :userinfo variables, as FTE keeps them (PR_AutoCvar, Cvar_SetCore).

server = QuakeServer.Autocvars.sync(server)

The host is a QuakeServer.Server (a server, a client program's world or a menu) holding a QuakeServer.Cvars table in cvars. The first sync/1 of a program attaches it, as FTE does when a program loads: each autocvar_ global (a float, integer, vector or string; not a float named like a vector's _x, _y or _z) names a variable, made when there is none with the global's own value as its default (%g for a float, %i for an integer, %g %g %g for a vector), and is given the variable's value; a variable programs may not read (:nounsafeexpand) is left out. On a server (one with player slots) every :serverinfo variable with a value becomes a server info key and every :userinfo one an info key of each player slot; one without a value removes its key.

Every later sync/1 whose table changed since the last brings every attached global and every info key up to date. A float global takes the variable's value, an integer its ival, a string its text (empty text the null string) and a vector the first three words of the text read as numbers. QuakeServer.Server.exec_opts/1 runs sync/1 before every call into a program, so a change made by any process holding the table reaches each program before it next runs.

Summary

Functions

A float as C's %g writes it: six significant digits, trailing zeros dropped.

Attach the host's program, or bring it up to date with its table; see the module documentation.

Functions

format_g(value)

@spec format_g(number()) :: String.t()

A float as C's %g writes it: six significant digits, trailing zeros dropped.

sync(host)

@spec sync(map()) :: map()

Attach the host's program, or bring it up to date with its table; see the module documentation.