Skip to main content
If you want to make your custom lua script have an own submenu then you will have to follow some extra steps. For this to work you script will have to return a table of elements that will be used for the submenu. You can look at this example to understand how it works.
-- values for the elements
local sliderValue = {
    selected = 1.0,
    min = 1.0,
    max = 100.0,
    step = 5.0
}

local comboValue = {
    selected = 1,
    values = { "test_value", "second_value" },
    words = { "Hello World", "Select me" }
}

local colorValue = {
    r = 255, g = 255, b = 255, a = 255,
    rainbow = false
}

local checkValue = {
    bool = false
}

-- the current value is only available if a slider, combo or check is clicked
-- otherwise it will be `nil`
function exampleOnClick(currentValue)
	print("Element clicked", currentValue)
end

-- table of elements that will be returned
return {
    {
        type = "button",
        text = "First Button",
        onClick = exampleOnClick
    },
    {
        type = "separator",
        text = "Other Stuff"
    },
    {
        type = "check",
        text = "Check me",
        value = checkValue,
    },
    {
        type = "slider",
        text = "Select a range",
        value = sliderValue,
        onClick = exampleOnClick
    },
    {
        type = "combo",
        text = "Select a type",
        value = comboValue,
        onClick = exampleOnClick
    },
    {
        type = "color",
        text = "Pick a color",
        value = colorValue
    },
    {
        type = "menubutton",
        text = "Open Test Submenu",
        value = "TestSubmenu"
    },
    {
        type = "submenu",
        text = "Test Submenu",
        value = "TestSubmenu",
        parent = nil, -- if `parent = nil` then the custom luas submenu will be used as parent
        elements = {
            {
                type = "button",
                text = "Second Button",
                onClick = exampleOnClick
            },
            {
                type = "menubutton",
                text = "Next Submenu",
                value = "SecondSubMenu"
            }
        }
    },
    {
        type = "submenu",
        text = "Test Submenu",
        value = "SecondSubMenu",
        parent = "TestSubmenu",
        elements = {
            {
                type = "button",
                text = "Third Button",
                onClick = exampleOnClick
            }
        }
    }
}