Baganator / Syndicator

World of Warcraft addon to keep track of where your items are in all your characters bags, banks, mails, void storage, auctions and guilds. Used by Baganator.
https://www.curseforge.com/wow/addons/syndicator
MIT License
5 stars 4 forks source link

[Feature Request] Custom keywords #27

Closed Pegoth closed 1 month ago

Pegoth commented 1 month ago

I would like to add my own keywords pragmatically.

If I modify the CheckItem.lua to add the following:

function Syndicator.Search.AddKeyword(keyword, check, group, force)
  if force then
    keyword = Syndicator.Search.CleanKeyword(keyword)
    KEYWORDS_TO_CHECK[keyword] = nil
    local i = 1
    while i <= #KEYWORD_AND_CATEGORY do
      if KEYWORD_AND_CATEGORY[i].keyword == keyword then
        table.remove(KEYWORD_AND_CATEGORY, i)
      else
        i = i + 1
      end
    end
  end
  AddKeyword(keyword, check, group)
end

(I added force to remove already existing keyword with that name.)

It seems to work and adds a keyword if I call it like this:

local function Example(details)
    return C_Item.IsItemKeystoneByID(details.itemID)
end

Syndicator.Search.AddKeyword("example", Example, nil, true)

So it would be nice to have it as an API (I can do a PR if you would like).

However, it seems like whatever I do the result is cached if I return either true or false, meaning I have to do a /reload to re-run the function. Calling the Syndicator.Search.ClearCache method did not help.

plusmouse commented 1 month ago

Is there a specific search you want to do but can't with the current Syndicator?

Pegoth commented 1 month ago

I like to add custom categories for various stuff and this would solve the issue without me needing to manually add each item to the specific category (in Baganator), so I could create a keyword with this API and then create a new category with another API in the Baganator and link the two by the "search" field (I'm currently writing an another issue for Baganator to be able to create categories from API).


Edit, for the issue created: https://github.com/Baganator/Baganator/issues/202

plusmouse commented 1 month ago

At least 99% of use cases work with the current search system. Do you have an example of how you'd use the API?

The search will already scan tooltips and process a myriad selection of item properties and you can combine search terms with &, |, (, ) and invert them with !.

plusmouse commented 1 month ago

As far as I'm concerned the search is already so complete as to not need an API. If you have a specific generic search term needed to create your category please submit it as a PR so everyone can use it.

Pegoth commented 1 month ago

I don't know why you are so against 10 rows of code. I even offered to write it and do a PR.

Edit: Never mind, I'll just do the PR, if you REALLY don't want this feature just reject it.

plusmouse commented 1 month ago

The reason is simple, I don't want to be placed in the position of processing support requests for broken categories or search because someone installed a broken or conflicting plugin, which is an inevitability, or maintaining interfaces that will impact future feature development.