1. #1
    Deleted

    Question Weak Auras - Custom Trigger Help

    Alright, I know that basically for the events field I either need,
    "FRIENDLIST_UPDATE" or "BN_FRIEND_TOON_ONLINE"

    Code:
    function()
      if(Friend's Name is X) then
        return true
      else
        return false
      end
    end
    I'm not quite sure which one I should use and what to place in the if() section of the box. Cheers!

  2. #2
    I had a quick search for documentation about those events, it's hard to find. It seems like they fire "when something happened" the first fires whenever there's an update to the friend list, like when someone changes status, logs in or out, when you open the pannel, etc. The second fires when somebody comes online but doesn't tell you who came on. If I'm wrong about this, I'd like to know. With that in mind you could listen for the BN_FRIEND_TOON_ONLINE event and then iterate over the friends list to see if your friend is on. Just guessing, something like this might work:
    Code:
    function()
    	local friend_name = "FRIEND NAME HERE"
    	
    	for i = 1, BNGetNumFriends() do
    		local presence_id, first_name, last_name, toon_name, toon_id, client, online, last_online, afk = BNGetFriendInfo(i)
    		local full_name = first_name .. " " .. last_name
    		if ((full_name == friend_name) and (online == true) and (FRIEND_WAS_ONLINE == false)) then
    			FRIEND_WAS_ONLINE = true
    			return true
    		end
    		if ((full_name == friend_name) and (online == false) and (FRIEND_WAS_ONLINE == true)) then
    			FRIEND_WAS_ONLINE = false
    		end
    	end
    	return false
    end
    EDIT: Just guessing at something that should work, I haven't tested it, i just looked at the signature for BNGetFriendInfo() and BNGetNumFriends() and bashed something together.
    Last edited by a21fa7c67f26f6d49a20c2c51; 2011-10-10 at 04:22 PM.

  3. #3
    Deleted
    Thanks, I'll give that a whack!

  4. #4
    Deleted
    Code:
    function()
    	local friend_name = "FRIEND NAME HERE"
    	
    	for i = 1, BNGetNumFriends() do
    		local presence_id, first_name, last_name, toon_name, toon_id, client, online, last_online, afk = BNGetFriendInfo(i)
    		local isFriend = (presence_id == BNet_GetPresenceID(friend_name))
    		if (isFriend and (online == true) and (FRIEND_WAS_ONLINE == false)) then
    			FRIEND_WAS_ONLINE = true
    			return true
    		end
    		if (isFriend and (online == false) and (FRIEND_WAS_ONLINE == true)) then
    			FRIEND_WAS_ONLINE = false
    		end
    	end
    	return false
    end
    BNGetFriendInfo returns an encrypted chatLink instead of the actual, clear-text name (privacy issues). Printing into chat will output the correct name (visually), but any comparison with the plain text link will fail.

  5. #5
    Quote Originally Posted by Treeston View Post
    BNGetFriendInfo returns an encrypted chatLink instead of the actual, clear-text name (privacy issues). Printing into chat will output the correct name (visually), but any comparison with the plain text link will fail.
    That's unfortunate. I had a bit of playing around looking at the UI escape sequences. It seems I could construct a string that match friends which was at least partially useful. For example consider a friend named "Benjamin White" and the following simplified example:
    Code:
      ...
    
      first_name_mask, last_name_mask = "|k00000000|k", "|k00000|k"
      local presence_id, first_name, last_name, ... = BNGetFriendInfo(i)
    
      if (first_name == "|Kg"..presence_id..first_name_mask) and (last_name = "|Ks"..presence_id..last_name_mask) then
        return true
      end
    
      ...
    That seemed to work a little too well. A friend with "similar length" names would also trigger it ("Susannah Rizzo" for example). While such an approach might be useful in some very rare edge cases--like looking for that one friend with the really long first and last name--it's not robust enough for general use (my siblings and I all have 5-letter first names so we'd all trigger it). Unfortunately I'm just not knowledgeable enough to find a way to crack this problem: there doesn't appear to be a way to uniquely identify a person on real-id by design.

  6. #6
    Deleted
    Look at the code I use - BNet_GetPresenceID also accepts the friend's name in plain text, making it possible to compare presenceID with the return value of BNGetFriendInfo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •