Closed GurliGebis closed 1 month ago
@davidmc24 like this?
That looks like it should work. I was thinking something more like this (untested pseudo-code):
local tooltipSource = select(5, C_PetJournal.GetPetInfoBySpeciesID(speciesId))
for i = 1, C_PetJournal.GetNumPetSources() do
if tooltipSource:find('^|c%w+' .. _G["BATTLE_PET_SOURCE_"..i]) then
return i
end
end
return -1
What does the '^|c%w+'
mean? :)
Also, should we change it to return an integer, instead of the string value, like it does now?
I have changed the code to use the for loop above - the find function doesn't seem to be working though, so I have kept the other way of checking. It seems to be working - does it look good to you?
Either integer or string value could be fine. Not sure which is actually better in this case. If one allows us to avoid needing to list all possible options and maintain that as Blizzard adds new sources, that would be nice.
The caret is a regex "start of line". The "|c" is the start of a color UI escape. The "%w+" is a lua character class, one or more time, for alphanumeric characters. See https://www.lua.org/manual/5.1/manual.html#5.4.1
Basically, it's trying to find tooltips that start with a color escape followed by a source local string.
Yeah, your version looks good to me.
Okay, for some reason, the regex isn't working for me. I'll merge and create a new release in a few minutes 🚀🙂
This should fix #21 and #40