LUA programming help

I’m trying to tweak a Weak Aura via LUA.

It’s processing the names of groups found in the group finder. Right now the name of the group is stored in “group.Name:GetText()”.

I’m trying to perform a search/match/contains/find/etc to look for keywords in the group name. In particular, I’m looking to identify spam entries that have “WTS” in the title.

I tried something like this:

if string.match(group.Name:GetText(), “WTS”) then

However the string.match() always comes back nil.
I’ve spent hours testing various things, and I can’t figure out why the match isn’t working.

If I do string.match("[WTS Mythic+FREE LOOT]", “WTS”), the function returns “WTS” correctly.

If I go onto LUA demo sites and test my code there, it works fine there too.

If I print group.Name:GetText(), it shows “[WTS Mythic+FREE LOOT]”, meaning the variable group.Name:GetText() has the same value as the string constant I used in the successful test.

Why does everything work in my tests, but it never works when I run this line?

if string.match(group.Name:GetText(), “WTS”) then

They are strings rendered as textures to protect them from being read by addons like World Quest Group Finder. If you escape the pipe chars you’ll see the actual |Ktext|k string

print(group.Name:GetText():gsub("|", "||"))

See https://wow.gamepedia.com/UI_escape_sequences#Other

1 Like