# UI

### UI Pseudocode

```lua
-- Pseudocode that shows most of the ui functions and how to use them

-- If you want to get a reference to an existing group or item, call .find
local double_tap_ref = ui.find("aimbot", "ragebot", "main", "double tap")

-- "ui.create" creates a group
-- in which you can add items such as switches, sliders, combos, etc.
local group_ref = ui.create("Group")

-- Some arguments can be optional, like the 2nd one in this function,
-- it will make its default value true
local switch_ref = group_ref:switch("Switch", true)

-- You can change its value
switch_ref:set(false)

-- Or you can "override" its value
-- This will allow you to change the value of the item
-- without changing its value in the menu or in the cheat's configuration
switch_ref:override(true)

-- Reset the previous override
switch_ref:override()

-- You can register a function that will be executed
-- every time the value of the item changes

-- The reference can be accessed from the arguments of the callback
switch_ref:set_callback(function(ref)
    -- You can access the value of the item by calling :get
    -- To access the value it's overriden to with :override, call :get_override
    print(string.format("New value: %s", ref:get()))
end)

-- If you want to what type of object the item is, you can call :get_type
-- print(switch_ref:type()) --> switch

-- You can attach other items to some types of items by calling :create
-- This will create and return a reference to the item group,
-- to which you can add other items
local switch_group_ref = switch_ref:create()

-- Our API offers a lot of overloads, you can either just provide a bunch of strings
-- or you can provide a table of strings
local combo_ref = switch_group_ref:combo("Combo", "Option A", "Option B", "Option C")

-- You can update the contents of combos, selectables, list, and listables with :update
combo_ref:update({"Option A"})

-- You can attach color pickers to some types of items,
-- but keep in mind that you won't be able to attach a group at the same time
local combo_color_picker_ref = combo_ref:color_picker(color(255, 0, 0, 255))

-- If you want to see what group the item belongs to, call :parent
-- print(group_ref == switch_ref:parent()) --> true
-- print(switch_group_ref == combo_ref:parent()) --> true

-- If you want to describe an item, you can call :tooltip,
-- which will display a text when you move the cursor over the item
switch_ref:tooltip("Some useful information.")

-- Further reading:
-- https://lua.neverlose.cc/documentation/variables/ui
-- DM Serene#1337 for any documentation errors
```

### Multi-Color Picker

```lua
-- create a group
local group_ref = ui.create("Example Group")

-- create a color picker in the group
local color_picker_ref = group_ref:color_picker("Example Color Picker", {
	["Simple"] = {
		color(255, 255, 255)
	},
	["Double"] = {
		color(255, 255, 255),
		color(0, 0, 0)
	},
	["Multiple"] = {
		color(255, 0, 0),
		color(0, 255, 0),
		color(0, 0, 255),
		color(255, 0, 255)
	},
})

-- print the available modes
for _, v in ipairs(color_picker_ref:list()) do
	print(v)

	-- [neverlose] Simple
	-- [neverlose] Multiple
	-- [neverlose] Double
end

events.render(function()
	-- get the currently selected mode and color(s)
	-- (the second returned value can be a table)
	local mode, colors = color_picker_ref:get()

	print(mode)

	-- get colors from a specific mode
	local top_left, top_right, bottom_left, bottom_right = unpack(color_picker_ref:get("Multiple"))

	render.gradient(
		vector(20, 20), vector(120, 120),
		top_left, top_right, bottom_left, bottom_right
	)
end)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-csgo.neverlose.cc/useful-information/script-examples/ui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
