Skip to main content

Set Control Value (ui_element.set_value)

This function is available in versions after 20260507

Declaration​

ok, info_or_err = ui_element.set_value(selector_or_element, value [, options ])

Parameters​

  • selector_or_element
    Table. A selector, an element returned by a query, or a coordinate table { x = X, y = Y }.
  • value
    String, integer, number, or boolean. Control value to set.
  • options
    Optional, table. See Common options.

Returns​

  • ok
    Boolean. true on success, nil on failure.
  • info_or_err
    Table on success, string failure reason on failure.

Description​

Use this API for controls that support direct value setting. For sliders, you may try a number from 0.0 to 1.0, or a percentage string such as "50%". If the target control does not actually change, this API may return nil, "value unchanged".

Example​

local ui_element = require("ui_element")

ui_element.set_value({
role = "slider",
index = 1,
}, 0.5)