Console Settings
Needs the internal running and needs_internal = true in script_info.
convar.get(name) -> seq | nil
convar.set_int(name, value) -> seq | nil
convar.set_float(name, value) -> seq | nil
convar.set_bool(name, value) -> seq | nil
convar.result(seq) -> ok, float, int | nilReads and changes the settings you would type into the game's own console, such as fps_max.
The answer comes later
Every call returns a number, seq, straight away. The game handles the request on a later tick. Pass seq to convar.result to get the answer:
convar.result(seq) returns | Meaning |
|---|---|
nil | Not done yet. Ask again on the next tick |
true, float, int | Done. For convar.get, the value as a number and as a whole number |
false | The setting does not exist, or could not be changed |
Only the most recent answers are kept, so read yours within a few ticks.
lua
script_info = { name = "read_fps_max", needs_internal = true }
local seq, done
function on_tick()
if done then return end
if not seq then
seq = convar.get("fps_max")
return
end
local ok, f, i = convar.result(seq)
if ok == nil then return end -- not done yet
print(ok and ("fps_max is " .. i) or "no such setting")
done = true
endChanging a setting
convar.set_int needs a whole number: 144 works, 144.5 is an error. convar.set_bool takes true or false. convar.set_float takes any number.
lua
local seq = convar.set_int("fps_max", 240)A change stays after your script stops. If your script changes a setting, change it back when you are done.
Returns nil when
needs_internal = trueis missing fromscript_info.- The internal is not running.
- 16 requests are already waiting, across
convar.*andchat.*together.
A name can be up to 63 characters.