# `QuakeServer.Console.Variables`
[🔗](https://github.com/jaman/quake_server/blob/v0.1.0/lib/quake_server/console/variables.ex#L1)

The console's commands about console variables, run on the host's
`QuakeServer.Cvars` table as FTE's `cmd.c` and `cvar.c` run them.

  * `set name value`, `seta`, `set_tp` — make the variable when there is none and
    set it (`seta` also archives it). The value is the rest of the line; a single
    quoted value may be followed by `// description`, and an unquoted one is cut at
    `//`, the rest its description. A variable made this way takes the description.
  * `setfl name value flags [description]` — `flags` letters `a` (archive), `u`
    (user info), `s` (server info); any other letter does nothing.
  * `toggle name [value [other]]` — between 0 and 1, or `value` and `other` (default
    the variable's default); a variable not there is made at 0
  * `inc name [amount]` — add `amount` (default 1)
  * `name` — print the value, its default and any latched value; `name value` sets it
  * `cvarreset [-a] [-g group] pattern` — set back to their defaults
  * `cvar_lockdefaults`, `cvar_purgedefaults`, `cvar_resettodefaults_all`,
    `cvar_resettodefaults_saveonly`, `cvar_resettodefaults_nosaveonly`
  * `vid_reload`, `vid_restart` — latched renderer and video variables take effect

Commands from the server (`from: :server`, FTE's commands from game code) cannot set
`:notfromserver` variables; `set` then reads the flags as `setfl` does, and a value
the server sets takes the variable over (`QuakeServer.Cvars.lock_from_server/3`)
unless it is the default.

# `from`

```elixir
@type from() :: :local | :server
```

# `tokens`

```elixir
@type tokens() :: [{String.t(), non_neg_integer(), non_neg_integer()}]
```

# `command`

```elixir
@spec command(
  QuakeServer.Server.t(),
  QuakeServer.Cvars.Cvar.t(),
  tokens(),
  String.t(),
  from()
) ::
  QuakeServer.Server.t()
```

Run a command naming variable `cvar`: with no value print it, as FTE's `Cvar_Command`
prints, otherwise set it to the value (the one word, or the rest of the line).

# `defaults`

```elixir
@spec defaults(QuakeServer.Server.t(), String.t()) :: QuakeServer.Server.t()
```

Run one of the commands that move every variable's default (`cvar_lockdefaults` and the like).

# `inc`

```elixir
@spec inc(QuakeServer.Server.t(), [String.t()], from()) :: QuakeServer.Server.t()
```

Run `inc name [amount]`.

# `renderer`

```elixir
@spec renderer(QuakeServer.Server.t()) :: QuakeServer.Server.t()
```

Run `vid_reload` or `vid_restart`: latched renderer and video variables take their latched values.

# `reset`

```elixir
@spec reset(QuakeServer.Server.t(), [String.t()]) :: QuakeServer.Server.t()
```

Run `cvarreset` with its words.

# `rest`

```elixir
@spec rest(String.t(), tokens(), non_neg_integer()) :: String.t()
```

The raw text of `line` from token `index` on, as FTE's `Cmd_Args` after that many words.

# `set`

```elixir
@spec set(QuakeServer.Server.t(), String.t(), tokens(), String.t(), from()) ::
  QuakeServer.Server.t()
```

Run `set`, `seta`, `set_tp` or `setfl` (`command`) with the line's `tokens`.

# `toggle`

```elixir
@spec toggle(QuakeServer.Server.t(), [String.t()]) :: QuakeServer.Server.t()
```

Run `toggle name [value [other]]`.

---

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