Przejdź do treści
Gothic MultiplayerMultiplayer
Gothic MP Wiki

MenuControl

A control of a menu tab: value, text, description, enabled and visible state, change handler.

since 0.1.30-alpha

Controls are created with the add... methods of MenuPage. In the examples control is any MenuControl.

Methods

getValue

since 0.1.30-alpha
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

since 0.1.30-alpha
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.

ParameterTypeDescription
valueboolean | number | integerToggle: 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

since 0.1.30-alpha
control:setText(text)

Changes the text: the name of a row, the text of a header, a paragraph or a button.

ParameterTypeDescription
textstringNew text.

Returns: boolean - false when the control was removed.

setDescription

since 0.1.30-alpha
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.

ParameterTypeDescription
textstringNew description.

Returns: boolean - false for other controls and when the control was removed.

setEnabled

since 0.1.30-alpha
control:setEnabled(enabled)

Enables or greys out the control. A greyed-out control is shown but cannot be changed or clicked.

ParameterTypeDescription
enabledbooleanfalse = greyed out.

Returns: boolean - false when the control was removed.

setVisible

since 0.1.30-alpha
control:setVisible(visible)

Shows or hides the control (the controls below move up).

ParameterTypeDescription
visibleboolean

Returns: boolean - false when the control was removed.

remove

since 0.1.30-alpha
control:remove()

Removes the control from its tab (also from an open window).

Returns: boolean - false when it was already removed.

onChange

since 0.1.30-alpha
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)
ParameterTypeDescription
handlerfun(value:boolean|number|integer)|nil Receives the new value (as getValue returns it).

Returns: boolean - false when the control was removed.

getPage

since 0.1.30-alpha
control:getPage()

Returns the tab the control belongs to.

Returns: MenuPage | nil - nil when the control was removed.

isValid

since 0.1.30-alpha
control:isValid()

Tells whether the control still exists.

Returns: boolean