# `QuakeServer.Extensions.Settings`
[🔗](https://github.com/jaman/quake_server/blob/v0.1.0/lib/quake_server/extensions/settings.ex#L1)

FTE's builtins about the engine around the program: console variables (`cvar`,
`cvar_string`, `cvar_set`, `cvar_setf`, `registercvar`, `cvar_defstring`,
`cvar_type`, `cvar_description`, `buf_cvarlist`, `cvars_haveunsaved`, as FTE's
`pr_bgcmd.c` runs them on the host's `QuakeServer.Cvars` table), server and player info
keys, which extensions and functions exist, calling functions by name, the time,
printing, console commands, registered stats, and the kinds of client.

`registercvar(name, value, flags)` takes the value only when given flags too, as FTE
reads its arguments; DarkPlaces flag bits 16 (cheat), 32 (archive), 256 (server
info), 512 (user info) and 2048 (private) are taken, any other is warned about.
`cvar_type` gives FTE's bits: 1 there, 2 archived, 4 private, 8 the engine's, 16 has
a description, 32 read only.

`readcmd` runs the console commands queued so far, then its text, and returns what
they printed, kept off the console, followed by `PF_readcmd: ` and the text, as FTE's
redirected console gives it.

Info keys live in the host's `ext.serverinfo` and `ext.userinfo` (by entity), stats in
`ext.stats`, registered commands in `ext.commands`.

# `call`

```elixir
@spec call(map(), integer() | String.t(), non_neg_integer()) :: map()
```

Run settings builtin `builtin` (a number or a name).

# `cvar_value`

```elixir
@spec cvar_value(map(), String.t()) :: float()
```

Console variable `name` as a server program's `cvar` reads it: `pr_checkextension` is
`checkextension`'s builtin number (0 when the variable is set to 0),
`pr_builtin_find` and `pr_map_builtin` 0, `halflifebsp` 1 on a Half-Life map; any
other name its value as `readable/2` finds it, 0 when there is none.

# `extension?`

```elixir
@spec extension?(String.t()) :: boolean()
```

Whether `name` is one of the extensions `checkextension` (99) reports, ignoring ASCII case, as FTE's menu program checks.

# `info`

```elixir
@spec info(map(), non_neg_integer(), String.t()) :: String.t()
```

Info key `key` of `entity`: the server's for the world, a player's own otherwise; `""` when unset.

# `info_string`

```elixir
@spec info_string(map()) :: String.t()
```

The server's info keys as an info string, `\key\value` for each.

# `put_info`

```elixir
@spec put_info(map(), non_neg_integer(), String.t(), String.t()) :: map()
```

Set info key `key` of `entity` (the world for the server's own). A change to the
server's own goes to every player reliably as `svc_serverinfo` (52, the key and value
as strings).

# `readable`

```elixir
@spec readable(map(), String.t()) :: QuakeServer.Cvars.Cvar.t() | nil
```

Console variable `name` as a program reads it (FTE's `PF_Cvar_FindOrGet`): made when
there is none and `pr_autocreatecvars` is set (empty, or `sv_maxairspeed` 30 and
`sv_jumpvelocity` 270), `nil` when it is not there or programs may not read it
(`:nounsafeexpand`).

# `server_key`

```elixir
@spec server_key(map(), String.t()) :: String.t()
```

Server key `key` as a client program reads it (`PF_cl_serverkey_internal`): `ip`
`loopback`, `servername` `local`, `constate` `active`, `pausestate` `1` or `0` by the
host's `ext.paused`, `maxplayers` `1`, `protocol` `QuakeWorld FTE`, `transferring` and
`dlstate` empty, `loadstate` `0 0 0 ""`; any other key from the server's info.

# `set_cvar`

```elixir
@spec set_cvar(map(), String.t(), String.t()) :: map()
```

Set console variable `name` to `value` as a program's `cvar_set` does: made when there
is none (`readable/2`), and left alone when no program may set it
(`:notfromserver`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
