Skip to content

mwseMCMCustomVariable⚓︎

This Variable class allows the user to provide custom getter and setter methods.

This type inherits the following: mwseMCMVariable

Properties⚓︎

class⚓︎

The type of the variable.

Returns:

  • result (string)

componentType⚓︎

The type of this component.

Returns:

  • result ("Variable")

converter⚓︎

This function is called when the value of the variable is changed. The function can modify the new value before it is stored.

Returns:

  • result (fun(newValue): unknown)

id⚓︎

The unique identifier for the variable.

Returns:

  • result (string)

inGameOnly⚓︎

If true, the setting containing this variable will be disabled while the game is on main menu.

Returns:

  • result (boolean)

restartRequired⚓︎

If true, updating the setting containing this variable will notify the player to restart the game.

Returns:

  • result (boolean)

restartRequiredMessage⚓︎

The default text is a localized version of: "The game must be restarted before this change will come into effect.".

Returns:

  • result (string)

value⚓︎

The value stored in the variable.

Returns:

  • result (unknown)

Methods⚓︎

get⚓︎

Returns the value stored in the variable.

local value = myObject:get()

Returns:

  • value (unknown)

getter⚓︎

This method returns the value currently stored in the Variable.

local currentValue = myObject:getter()

Returns:

  • currentValue (unknown)

new⚓︎

Creates a new variable of this type.

local variable = myObject:new({ id = ..., getter = ..., setter = ..., inGameOnly = ..., numbersOnly = ..., restartRequired = ..., restartRequiredMessage = ..., converter = ... })

Parameters:

  • variable (table)
    • id (string): Optional. The unique identifier for the variable.
    • getter (fun(self: mwseMCMCustomVariable): unknown): The custom getter function.
    • setter (fun(self: mwseMCMCustomVariable, newValue: unknown)): The custom setter function.
    • inGameOnly (boolean): Default: false. If true, the setting containing this variable will be disabled if the game is on main menu.
    • numbersOnly (boolean): Default: false. If true, only numbers will be allowed for this variable in TextFields.
    • restartRequired (boolean): Default: false. If true, updating the setting containing this variable will notify the player to restart the game.
    • restartRequiredMessage (string): Optional. The default text is a localized version of: "The game must be restarted before this change will come into effect.".
    • converter (fun(newValue): unknown): Optional. This function is called when the value of the variable is changed. The function can modify the new value before it is saved.

Returns:


set⚓︎

Changes the value stored in the variable. Calls the converter function with the new value before saving.

myObject:set(newValue)

Parameters:

  • newValue (unknown)

setter⚓︎

This method is called when a new value is saved to the Variable. If the Variable has a converter defined, the converter is called first. Then, the returned value is passed to this method.

myObject:setter(newValue)

Parameters:

  • newValue (unknown)