focusedArray

Focus on a specific elements in an array via their

Parameters description

ParameterTypeDescriptionDefault

array

table[]

The array to focus in

---

focus

table<string, any>

the key and value that can be found in the elements you want to focus

---

cb

fun(i: integer, curr: any)?

the callback function, triggered when match is found in the elements

---

Example

local db = {
    {
        name = 'menu1',
        type = 'context'
    },
    {
        name = 'menu2',
        type = 'dialog'
    },
    {
        name = 'menu3',
        type = 'context'
    }
}

RegisterCommand('showContextMenus', function()
    print('All context menus:')

    HRLib.table.focusedArray(db, { type = 'context' }, function(_, curr)
        print(curr.name)
    end)
end)
--[[ Output:
    All context menus:
    menu1
    menu3
]]

Last updated