MenuControl
A control of a menu tab: value, text, description, enabled and visible state, change handler.
Controls are created with the add... methods of MenuPage. In the examples control is any MenuControl.
Methods
getValue
control:getValue()Returns the current value: a boolean (toggle), a number (slider) or the index of the selected
item (list, 1 = the first one).
Returns: boolean | number | integer | nil - nil for headers, texts and buttons, and when the control was removed.
setValue
control:setValue(value)Sets the value (the row shows it at once; a value with a save key is remembered). Does not call
the onChange function - it reports changes made by the player.
| Parameter | Type | Description |
|---|---|---|
value | boolean | number | integer | Toggle: boolean; slider: number (clamped to its range); list: item index (clamped to the items). |
Returns: boolean - false for headers, texts and buttons, and when the control was removed.
setText
control:setText(text)Changes the text: the name of a row, the text of a header, a paragraph or a button.
| Parameter | Type | Description |
|---|---|---|
text | string | New text. |
Returns: boolean - false when the control was removed.
setDescription
control:setDescription(text)Changes the description shown in the panel on the right (toggles, sliders, lists). It is shown the next time the control is selected.
| Parameter | Type | Description |
|---|---|---|
text | string | New description. |
Returns: boolean - false for other controls and when the control was removed.
setEnabled
control:setEnabled(enabled)Enables or greys out the control. A greyed-out control is shown but cannot be changed or clicked.
| Parameter | Type | Description |
|---|---|---|
enabled | boolean | false = greyed out. |
Returns: boolean - false when the control was removed.
setVisible
control:setVisible(visible)Shows or hides the control (the controls below move up).
| Parameter | Type | Description |
|---|---|---|
visible | boolean |
Returns: boolean - false when the control was removed.
remove
control:remove()Removes the control from its tab (also from an open window).
Returns: boolean - false when it was already removed.
onChange
control:onChange(handler)Sets the function called when the player changes the value (toggles, sliders, lists) - also with
the window's RESET button. One function per control - a new call replaces the previous one; nil removes it.
slider:onChange(function(value) triggerServerEvent("loremIpsum", value) end)| Parameter | Type | Description |
|---|---|---|
handler | fun(value: | boolean|number|integer)|nil Receives the new value (as getValue returns it). |
Returns: boolean - false when the control was removed.
getPage
control:getPage()Returns the tab the control belongs to.
Returns: MenuPage | nil - nil when the control was removed.
isValid
control:isValid()Tells whether the control still exists.
Returns: boolean
