Client Menus
OpenMenu
Opens a customisable menu or form. A menu can be used whilst moving around whilst a form takes full control of the users UI.
closeHandler
Function
A function that gets triggered when the menu is closed.
selectHandler
Function
A function that gets triggered when using a menu and the highlighted field is modified.
changeHandler
Function
A function that gets triggered when a value within the form gets changed or a button element is pressed.
{ -- Settings
namespace = '', -- String, required
title = '', -- String
subtitle = '', -- String
searchable = false, -- Boolean, only available for forms
form = false, -- Boolean, enables direct input including mouse
disableFormButtons = false, -- Boolean, disables Confirm/Cancel buttons on the form. Will always return "complete" as false within the close handler
}{
type = '', -- String, defaults to button (text, checkbox, toggle, slider, select, button, linebreak, subtitle, number). 'select', 'number' and 'text' automatically enable the form option for the menu
name = '', -- String, required. Refernce for any return event. Not required for linebreak or subtitle
label = '', -- String, required. Display label. Not required for linebreak
value = nil, -- Anything, sets default value if applicable
disabled = false, -- Boolean
required = false, -- Boolean, force validation on input
regex = '', -- String, regex string for validating input. You can also pass the term `json` in order to activate JSON validation
validationMessage = '', -- String, required if regex is in use. Set the message to display to the end user
-- Subtitle
size = nil, -- Number, font size in VH units
position = nil, -- String, any applicable text-align variables I.e. left, right, center
margin = nil, -- Number, margin to apply in VH units. Can be negative to reduce the spacing between elements (I.e. -1)
-- Text
multiline = false, -- Boolean, used to change from a single line input to a text box (type of 'text' only)
-- Button/Number
icon = '', -- String (type of 'button' or 'number' only). Can change to any FontAwesome (including Pro) icons. Use full reference. I.e. `fad fa-heart`
description = '', -- String (type of 'button' or 'number' only)
-- Select
options = { -- Array of options (type of 'select' only)
{
value = '', -- String, required
label = '', -- String, falls back to value if not specified
}
},
multiselect = false, -- Boolean, used to allow multiple selections
-- Slider
step = 1, -- Number (type of 'slider' only). Used to specify the jump step of the slider
min = 0, -- Number (type of 'slider' or 'number' only). The minimum value of the slider
max = 100, -- Number (type of 'slider' or 'number' only). The maxmimum value of the slider
}UpdateMenuElement
Can handle any element data apart from type. See Menu Element Object for the element structure. Only name is required and it will only update the fields that are provided.
TMC.Functions.UpdateMenuElement({
name = 'text_test',
multiline = true,
label = 'An Updated Text Test',
value = 'Forced value',
disabled = true
})
TMC.Functions.UpdateMenuElement({
name = 'button_test',
icon = 'fas fa-heartbeat',
disabled = false
})RemoveMenuElement
Can handle any element. Used to remove an element from a form.
TMC.Functions.RemoveMenuElement({
name = 'text_test'
})StartSideMenuUi
These use direct callbacks based on the menu type. You will need to use TMC.Functions.RegisterUiHandler instead of callbacks.
menuRef
String
Reference to the side menu which events should be triggered for.
disableCancel
Bool
Disable the cancel button.
closeOnly
Bool
Hides both Confirm and Cancel buttons and puts a Close button in it's place.
initialTab
String
A reference to the initial category to show. When left blank it will default to the first category in the list.
{
name = '', -- String, required
label = '', -- String, required
icon = '', -- String, required (FontAwesome ref)
disabled = false, -- Boolean
searchable = false -- Boolean, add filter/search box to tab
}{
type = '', -- String, defaults to `default` (default, grid-slider, text, checkbox, toggle, slider, select, button, linebreak, subtitle, colour-picker, preview-select)
name = '', -- String, required. Refernce for any return event. Not required for linebreak or subtitle
label = '', -- String, required. Display label. Not required for linebreak
cat = '', -- String, required. The category to place the element in
val = nil, -- Anything, sets default value if applicable. See types of select, default and grid-slider below
disabled = false, -- Boolean
-- Subtitle
size = nil, -- Number, font size in VH units
position = nil, -- String, any applicable text-align variables I.e. left, right, center
margin = nil, -- Number, margin to apply in VH units. Can be negative to reduce the spacing between elements (I.e. -1)
-- Text
multiline = false, -- Boolean, used to change from a single line input to a text box (type of 'text' only)
-- Button / Preview Select
icon = '', -- String (type of 'button' or 'preview-select' only). Can change to any FontAwesome (including Pro) icons. Use full reference. I.e. `fad fa-heart`
description = '', -- String (type of 'button' only)
-- Select / Preview Select
options = { -- Array of options (type of 'select' or 'preview-select' only)
{
value = '', -- String, required
label = '', -- String, falls back to value if not specified
colour = '', -- String, rgba/hex code for preview colour. Only used for colourSwatch mode on 'select' type
}
},
selectedOption = nil, -- Must match a value from the options table and sets the default value
colourSwatch = false, -- Boolean, enable colour swatch mode ('select' type only)
multiselect = false, -- Boolean, used to allow multiple selections (cannot be used in colourSwatch mode)
-- Slider
step = 1, -- Number (type of 'slider' only). Used to specify the jump step of the slider
min = 0, -- Number (type of 'slider' only). The minimum value of the slider
max = 100, -- Number (type of 'slider' only). The maxmimum value of the slider
-- Default
minItem = -1, -- Number
maxItem = 100, -- Number
minText = 0, -- Number
maxText = 100, -- Number
item = -1, -- Number, used for default values
text = 0, -- Number, used for default values
labelItem = 'Item', -- String
labelText = 'Texture', -- String
disableTexture = false,
disableTextureChange = false, -- Boolean, used to disable the texture being automatically reset to 0 when the item updates
-- Grid Slider
minX = 0, -- Number
maxX = 0, -- Number
minY = 0, -- Number
maxY = 0, -- Number
valX = 0, -- Number, used for default values
valY = 0, -- Number, used for default values
labelXPos = '', -- String
labelXNeg = '', -- String
labelYPos = '', -- String
labelYNeg = '', -- String
}Controls must be formatted into rows. This allows you to add multiple rows to a list of controls. I.e.
{ -- Control rows array
{ -- Controls array
{ -- Control Object
name = '', -- String, required
icon = '', -- String, required
tooltip = '', -- String, tooltip/label when button is hovered
allowHold = false, -- Boolean, repeat button press whilst holding
holdInterval = 200, -- Number, interval in milliseconds when holding button. Defaults to 200
}
}
}StopSideMenuUi
Close any open side menu
TMC.Functions.StopSideMenuUi()RegisterUiHandler
In order to receive event updates for the side menu you can register UI handlers. These handlers will be triggered when the side menu changes them.
When registering a handler you will need to prepend your menuRef to the handler.
I.e. to register a handler for a control click with a menu type of clothing you would do:
TMC.Functions.RegisterUiHandler('clothingControlSideMenu', function(data, cb)
end)Available events for side menu:
CreateSideMenuElement
Can add an element to an open side menu. See Side Menu Element Object for the element structure.
TMC.Functions.CreateSideMenuElement({
name = 'additionalField',
label = 'An additional field',
type = 'text',
cat = 'testCat1'
})UpdateSideMenuElement
Can handle any element data apart from type. See Side Menu Element Object for the element structure. Only name is required and it will only update the fields that are provided.
TMC.Functions.UpdateSideMenuElement({
name = 'slider',
label = 'Updated Slider Label'
})DeleteSideMenuElement
Remove an element from the side menu. Requires only the name of the element.
TMC.Functions.DeleteSideMenuElement('text2')UpdateSideMenuCategory
Can handle any category data. See Side Menu Category Object for the category structure. Only name is required and it will only update the fields that are provided.
TMC.Functions.UpdateSideMenuElement({
name = 'testCat2',
disabled = true
})SetSideMenuTab
Update the current visible tab. Force the user to switch onto another tab. Requires the category name.
TMC.Functions.SetSideMenuTab('testCat2')Last updated