Weird result from string operations on BNet friends
Hello,
I was trying to make a quick addon but stumbled upon this which I can just assume is me doing something really wrong. The plan was to filter BNet friend requests by name etc. I have a function Code:
function self:GetFriendInviteName(i) Macro: Code:
/run local w = nx_Talents:GetFriendInviteName(1); print(w); print(string.find(w,".......")); print(string.match(w,".......")); Code:
|Kb5|kGM6767|k |
Most Battle.net functions return |K escape sequences instead of actual real names. These are translated to real names by the client outside of the UI, so AddOns and scripts can't see anything more than the escape sequence.
Presumably the b character represents a BattleTag name instead of a given name, surname or full name. |
Thank you! That explains the weird output. However, I am still having serious issues with the string matching. Even running
Code:
/run local _,w = BNGetFriendInviteInfo(1); print(w); print(string.match(w,"GM")); Code:
|Kb5|kGM6767|k Code:
/run local _,w = BNGetFriendInviteInfo(1); print(w); print(string.match(w,".............")); Code:
|Kb5|kGM6767|k |
The "|k000000|k" sequence is replaced with the real text internally. You can print it or SetText with it and get the expected text shown on the screen, but you can't actually see it in Lua code or manipulate with the Lua string functions. This is intentional, and there is no way around it. Addon code cannot tell what the contents of the "|k" sequence are, period.
It's also worth noting that you can trim the sequence by removing some of the 0 characters (so if "|k00000|k" is "Phanx" then "|k00|k" is just "Ph") but extra 0s are just ignored ("|k00000000000000|k" is still just "Phanx"). |
All times are GMT -6. The time now is 10:44 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI