evasivedocs
CS2 scriptingLua 5.4.9 · 25 guides · 292 API entries
API reference

Settings UI and config

Your script's own settings, and evasive's settings and profiles.

ui

Controls in the script's group of the menu (Scripts > Settings), saved in the user's config. Each returns a Control.

11 entries

ui.checkbox

function
ui.checkbox(label [, default]) -> Control

Checkbox in the script's settings group. Labels are ids; add ##suffix to repeat a label.

Arguments
NameTypeDefaultDescription
labelstring
defaultoptionalbooleanfalse
Returns
  • Control
Example
Lua
local enabled = ui.checkbox("Enabled", true)

ui.slider

function
ui.slider(label, min, max [, default [, opts]]) -> Control

Slider; opts = {decimals = 0..4, suffix = "px"}.

Arguments
NameTypeDescription
labelstring
minnumber
maxnumber
defaultoptionalnumber
optsoptionaltable
Returns
  • Control
Example
Lua
local size = ui.slider("Size", 1, 40, 10, {suffix = "px"})

ui.combo

function
ui.combo(label, items [, default]) -> Control

Single choice (1-based index; at most 64 items).

Arguments
NameTypeDefaultDescription
labelstring
itemsstring[]
defaultoptionalinteger1
Returns
  • Control
Example
Lua
local mode = ui.combo("Mode", {"Text", "Circle"}, 1)

ui.multi_combo

function
ui.multi_combo(label, items [, default]) -> Control

Multiple choice; :get() returns a table of booleans.

Arguments
NameTypeDescription
labelstring
itemsstring[]
defaultoptionalboolean[]
Returns
  • Control
Example
Lua
local parts = ui.multi_combo("Parts", {"Head", "Body"}, {true, false})

ui.color

function
ui.color(label [, default]) -> Control

Colour swatch on the right of the previous row.

Arguments
NameTypeDescription
labelstring
defaultoptionalcolor
Returns
  • Control
Example
Lua
local col = ui.color("Colour", color(143, 108, 240))

ui.keybind

function
ui.keybind(label [, key [, mode]]) -> Control

Key binding; mode "hold", "toggle" or "always". Use :active().

Arguments
NameTypeDefaultDescription
labelstring
keyoptionalinteger0
modeoptionalstringhold
Returns
  • Control
Example
Lua
local key = ui.keybind("Key", vk.f, "toggle")

ui.text_input

function
ui.text_input(label [, default [, max_len]]) -> Control

Single-line text field.

Arguments
NameTypeDefaultDescription
labelstring
defaultoptionalstring
max_lenoptionalinteger64
Returns
  • Control
Example
Lua
local label = ui.text_input("Label", "hello", 32)

ui.button

function
ui.button(label, callback) -> Control

Button; the callback runs on the next frame (inside the budget).

Arguments
NameTypeDescription
labelstring
callbackfunction
Returns
  • Control
Example
Lua
ui.button("Reset", function() storage.set("n", 0) end)

ui.label

function
ui.label(text) -> Control

A line of text.

Arguments
NameTypeDescription
textstring
Returns
  • Control
Example
Lua
ui.label("Made by me")

ui.separator

function
ui.separator([title]) -> Control

A titled separator.

Arguments
NameTypeDescription
titleoptionalstring
Returns
  • Control
Example
Lua
ui.separator("Advanced")

ui.accent

function
ui.accent() -> color

The menu accent colour.

Returns
  • color
Example
Lua
draw.rect_filled(0, 0, 10, 10, ui.accent())

config

Read and change evasive's own settings and profiles.

6 entriesAllow scripts to edit cfg files

Everything here needs Allow scripts to edit cfg files in Scripts > Security (off by default).

config.get

function
config.get(path) -> any

An evasive setting by its path "section.field" (the blocks and keys of config/<name>.cfg).

Arguments
NameTypeDescription
pathstring
Returns
  • any
Example
Lua
local on = config.get("esp.enabled")

config.set

function
config.set(path, value) -> boolean

Changes an evasive setting (same type as the current value). Not saved until config.save().

Arguments
NameTypeDescription
pathstring
valueany
Returns
  • boolean
Example
Lua
config.set("esp.enabled", false)

config.save

function
config.save() -> boolean

Saves the active profile.

Returns
  • boolean
Example
Lua
config.save()

config.active

function
config.active() -> string

Name of the active profile.

Returns
  • string
Example
Lua
log.info(config.active())

config.list

function
config.list() -> string[]

Profile names.

Returns
  • string[]
Example
Lua
for _, n in ipairs(config.list()) do end

config.load

function
config.load(name) -> boolean

Switches to another profile (script values from it apply; the loaded-script set is not changed from a script).

Arguments
NameTypeDescription
namestring
Returns
  • boolean
Example
Lua
config.load("legit")

Control

A menu control, returned by ui.*.

6 entries

Control:get

method
Control:get() -> any

Current value: boolean, number, integer (combo, 1-based), boolean[] (multi_combo), color, integer (keybind key), string.

Returns
  • any
Example
Lua
if enabled:get() then end

Control:set

method
Control:set(value)

Sets the value (labels: the text).

Arguments
NameTypeDescription
valueany
Example
Lua
enabled:set(false)

Control:active

method
Control:active() -> boolean

Keybinds: held (hold), toggled (toggle) or always. False while the menu is open or a text field has focus.

Returns
  • boolean
Example
Lua
if key:active() then end

Control:visible

method
Control:visible(shown)

Shows or hides the control.

Arguments
NameTypeDescription
shownboolean
Example
Lua
size:visible(enabled:get())

Control:on_change

method
Control:on_change(callback)

Called with the new value when the control changes (menu, profile load or :set).

Arguments
NameTypeDescription
callbackfunction
Example
Lua
enabled:on_change(function(v) log.info(v) end)

Control:name

method
Control:name() -> string

The display label.

Returns
  • string
Example
Lua
local n = enabled:name()