Methods

Learn more about methods of a pui element

Complete list of methods
  • set(...)

  • get(find)

  • override(value)

  • get_original()

  • reset()

  • update(list)

  • get_list()

  • get_color()

  • set_color(...)

  • get_hotkey()

  • set_hotkey()

  • is_reference()

  • get_type()

  • get_name()

  • set_visible(state)

  • set_enabled(state)

  • depend(pair1, pair2, ..., pairn)

  • set_callback(fn, once)

  • detach_callback(fn)

  • invoke(...)

Metamethods:

  • __type = "pui::element" / "pui::group" / "pui::player_slot"

  • __name = "pui::element" / "pui::group"

  • __tostring -- e.g. pui.checkbox[18] "Enable"

  • __call() = get()

  • __call(...) = set(...)

  • __metatable = false

:override(...)

:override is a feature in gamesense pui version that allows you to override values of elements and easily revert them like in neverlose.

local enable_aa = pui.reference("AA", "Anti-aimbot angles", "Enabled")

-- disabling aa:
enable_aa:override(false)

-- don't leave a mess behind you
defer(function()
    enable:override() -- or enable:override(nil)
end)

if you need the original value while the element is overridden, use :get_original()

:depend(...)

Sometimes you want to hide certain elements to not mess up the menu. It might look simple but actually it's rather difficult and complicated. But pui can make this as easy as pie.

:depend(...) is a method of a pui element, which creates a dependence on elements passed as arguments.

Its arguments can be either elements themselves (generally switches), or tables, which contain ref, condition, ....

In most of the cases, it looks like this: :depend( {ref, condition}, {ref2, condition2}, ... )

You can also invert conditions like this: {ref, condition, true}

If you want to lock elements instead of hiding them: :depend(true, ...)

Study these examples:

This is a common example of the use of :depend(...). As you can see, there are two labels showing statuses of a switch.

local checkbox = group:checkbox("Master switch")
local status1 = group:label("...is enabled!")
local status2 = group:label("...is disabled!")

status1:depend( {checkbox, true} )
status2:depend( {checkbox, false} )

There are a lot of ways to use :depend() that I can't even imagine.

:set_callback(func, once*)

It's pretty much the same as the built-in ui.set_callback(), but pui allows you to add multiple callbacks and execute them at least once. You can also unset them by using :unset_callback(func) . You can't unset anonymous functions.

local checkbox = pui.checkbox("LUA", "A", "Enable")

checkbox:set_callback(function(self)
    printf("Hello, %s is my name, %s is my value", self.name, self.value)
end, true)

checkbox:set_callback(function(self)
    printf("I was changed to %s!", self.value)
end)

:set_event(event, func, condition*)

This methods is used to call functions in events when a certain condition is met. You can unset this behavior via :unset_event(event, func). You can't unset anonymous functions.

local checkbox = pui.checkbox("CONFIG", "Presets", "Name")

local painter = function (cmd)
    print(cmd.chokedcommands)
end

checkbox:set_event("setup_command", painter)

:get_color() and :get_hotkey()

These will return the value of an additional elements.

local c1 = pui.checkbox("LUA", "A", "Checkbox", {120, 160, 80})
local r, g, b, a = { c1:get_color() } -- 120, 160, 80, 255
local color = c1.color.value  -- { 120, 160, 80, 255 }
local color2 = { c1.color:get() } -- 120, 160, 80, 255

local c2 = pui.checkbox("LUA", "A", "Checkbox", 1)
local is_active, key = { c2:get_hotkey() } -- true, 1
local hotkey = { c2.hotkey:get() } -- true, 1
local hotkey2 = c1.hotkey.value  -- { true, 1 }

Last updated