Thread Tools Display Modes
03-16-14, 09:48 PM   #1
Foxthorn
A Deviate Faerie Dragon
 
Foxthorn's Avatar
Join Date: Apr 2009
Posts: 16
Can't get toon ID -> presence ID in Battle.net functions?

So in 5.4.7 Blizzard added some Battle.net functions to allow sending invisible addon data. However, there doesn't seem to be any way to take a Battle.net toon presence ID (which identifies a specific character on your BN friends list) and get the presence ID of the actual BN friend who owns that character.

BN_CHAT_MSG_ADDON returns four values - addon prefix, text, “WHISPER”, and senderToonID.
senderToonId, as far as I can tell, cannot be used directly to interact with or get information about a BN friend. Meaning you can't even respond to a BN_CHAT_MSG_ADDON with a BNSendGameData(presenceID)...

BNGetToonInfo(toonID) returns a presence ID (as its last return value), but it's the toon ID, not the friend's presence ID... Is there something I'm missing or can you really not convert a toon ID to a presence ID? Am I going to have to iterate over every single BN friend and check if each one's current toon ID matches the toon ID returned by BN_CHAT_MSG_ADDON?
  Reply With Quote
03-16-14, 11:38 PM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
BNGetToonInfo seems to literally return whatever value you give it, making its final return value completely pointless.

If BNSendGameData works like BNSendWhisper, then you can use the presence and toon IDs interchangeably to send messages.

However, if you do need the presence ID from the toon ID you can loop over online friends with BNGetFriendInfo or BNGetFriendToonInfo and compare the toon IDs or just watch the BN login events and keep a reference table of [toonID] = presenceID.

edit: I just tested it and you can use either the presence ID or the toon ID with BNSendGameData.

Last edited by semlar : 03-17-14 at 12:00 AM.
  Reply With Quote
03-17-14, 08:09 AM   #3
Foxthorn
A Deviate Faerie Dragon
 
Foxthorn's Avatar
Join Date: Apr 2009
Posts: 16
Originally Posted by semlar View Post
edit: I just tested it and you can use either the presence ID or the toon ID with BNSendGameData.
Okay, thanks for confirming that. I mainly want to show the real name in BN_CHAT_MSG_ADDON so I guess I'll have to loop through BNGetFriendInfo and look for the one with the correct toonID.
  Reply With Quote
03-17-14, 01:08 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Foxthorn View Post
Okay, thanks for confirming that. I mainly want to show the real name in BN_CHAT_MSG_ADDON so I guess I'll have to loop through BNGetFriendInfo and look for the one with the correct toonID.
You should probably implement a cache of some kind so you're not running that loop every time you receive a message. I'd use a metatable:

Lua Code:
  1. local nameFromToonID = setmetatable({}, { __index = function(t, k)
  2.     local _, numFriends = BNGetNumFriends()
  3.     for i = 1, numFriends do
  4.         local _, presenceName, _, _, _, toonID = BNGetFriendInfo(i)
  5.         if toonID == k then
  6.             t[k] = presenceName
  7.             return presenceName
  8.         end
  9.         -- Remove this inner loop if you don't have any friends who multibox under a single Battle.net account
  10.         for j = 1, BNGetNumFriendToons(i) do
  11.             local _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, toonID = BNGetFriendToonInfo(i, j)
  12.             if toonID == k then
  13.                 t[k] = presenceName
  14.                 return presenceName
  15.             end
  16.         end
  17.     end
  18. end })
  19.  
  20. -- Look up like so:
  21. local presenceName = nameFromToonID[toonID]
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Can't get toon ID -> presence ID in Battle.net functions?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off