local lightgreencolor = Color(0xff90ee90)

local Searcher = {}
 Searcher.isOn = {}
 Searcher.timepoint1 = 0
 Searcher.timepoint2 = 0

 Searcher.flash = function (inventory, i)
  inventory.visualSlots[i+1].ShowBorderHighlight(lightgreencolor, 0.5, 0.5, 0.2)
end

Searcher.blink = function (inventory)
    for i, enabled in pairs(Searcher.isOn) do
        if enabled then 
            Searcher.flash(inventory, i)
        end
    end
end

Searcher.FindItem = function (inventory, query, recursive)
    for item in inventory.AllItemsMod do
        if item and string.find(string.lower(item.Name), string.lower(query)) then return true
        if recursive and item.OwnInventory and Searcher.FindItem(item.OwnInventory,query,true) then
            return true
        end
    end
    return false
end

Searcher.resetIsOn = function ()
    for i, _ in pairs(Searcher.isOn) do
        Searcher.isOn[i] = nil
    end
end

Searcher.printIsOn = function ()
    for _, value in pairs(Searcher.isOn) do
        print(_, value)
    end
end

Searcher.Search = function (inventory, query)
    Searcher.resetIsOn()
    for i = 0, inventory.Capacity - 1 do
        item = inventory.GetItemAt(i)
        if (item and string.find(string.lower(item.Name), string.lower(query))) or
        (item and item.OwnInventory and Searcher.FindItem(item.OwnInventory, query, true)) then
            --print("query item found at index ".. i)
            Searcher.isOn[i] = true
        else
            Searcher.isOn[i] = false
        end
    end
    --blink(inventory)
end

return Searcher

--item.Name == query





