+ Reply to Thread
Results 1 to 7 of 7

Thread: Problems with inspecting buffs

  1. #1
    Soulwalker
    Join Date
    Sep 2011
    Posts
    16

    Default Problems with inspecting buffs

    I'm having an issue getting the buffs on the player. The inspect call always returns either nil or an empty table. Here's what I've tried so far:

    Code:
    Inspect.Buff.List("player") -- always returns an empty table
    
    Inspect.Buff.List("player.target") -- if there's a target an empty table else nil
    
    p = Inspect.Unit.Lookup("player")
    Inspect.Buff.List(p) -- always returns an empty table
    Obviously I'm missing something...anyone have some advice?

  2. #2
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default

    Is the player an available unit? Check with Event.Unit.Available(unit) on live, or Event.Unit.Availability.Full(unit) on the PTS. Once you are sure the player is valid and loaded into the world, use Event.Buff.Add, Event.Buff.Change, and Event.Unit.Remove as appropriate. Depending on what you are doing, you might be able to skip registering for Event.Unit.Available / Event.Unit.Availability.Full and just check the buff events.

    The API for checking a unit's buffs is the following, which returns a table of IDs.
    Code:
    local buffs = Inspect.Buff.List("player")
    The entire API is documented, which once again, I would like to thank Trion for publicly releasing.

  3. #3
    Soulwalker
    Join Date
    Sep 2011
    Posts
    16

    Default

    Yes the unit is available (the unit I'm trying to inspect is me). The API call you mentioned was the one I was using, but it returns an empty table irrespective of what buffs/debuffs are on me.

  4. #4
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    The call definitely works (I use it a lot).

    If you have the Trion development tools addon installed, try typing:

    /script dump(Inspect.Buff.List("player"))

    I did that, and the result was:

    Code:
    07:22:33: [/script] {  
      b800000011E1402B1 = true, 
      b800000011E1402B3 = true, 
      b800000011E1402B5 = true, 
      b800000011E1402B9 = true, 
      b800000011E1402BD = true, 
      b800000011E1402BF = true, 
      b800000011E1402C3 = true, 
      b800000011E1402E1 = true, 
      b800000011E1402E5 = true
    }
    If you're trying this within an addon, and are just calling it straight from the file as your addon starts, the player won't be available yet, which I think is probably what's happening.

    As Lorandii says, you have to handle Event.Unit.Available and wait until the player is available. It might seem like the player is available all of the time, but it's not - at addon startup (and while zoning), the player actually becomes unavailable and you can only query some very basic partial information.
    Last edited by DoomSprout; 06-14-2012 at 11:28 PM.

    Gadgets: Unit Frames and Other Stuff for RIFT

  5. #5
    Soulwalker
    Join Date
    Sep 2011
    Posts
    16

    Default

    Thanks very much for the reply, I tried your line and it worked as you said. However if I type
    Code:
    /script print(#Inspect.Buff.List("player"))
    I get 0. A call to dump listed returns a list similar to what you're showing. Also I'm calling this in Event.Combat.Damage and it's called on the the player so the player should be available at that time.

  6. #6
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Quote Originally Posted by jakkaxe View Post
    Thanks very much for the reply, I tried your line and it worked as you said. However if I type
    Code:
    /script print(#Inspect.Buff.List("player"))
    I get 0. A call to dump listed returns a list similar to what you're showing. Also I'm calling this in Event.Combat.Damage and it's called on the the player so the player should be available at that time.
    The #-operator only considers the continuous numerical part of a table starting at index 1. Your table has only strings as keys. I suggest to look up the length operator, as that may cause bugs if not used properly. It's intertwined with the difference between pairs and ipairs.

  7. #7
    Soulwalker
    Join Date
    Sep 2011
    Posts
    16

    Default

    That was it. I can inspect all the details in the table using pairs. Changed my code to

    Code:
    local buffs = Inspect.Buff.List("player") -- I actually save this on hit, but listed here just to show what it is
    local buffdetails = Inspect.Buff.Detail("player", buffs)
    for id, detail in pairs(buffdetails)
      -- process the detail table
    end
    and it works like a champ! Thanks everyone for your help!

+ Reply to Thread

Bookmarks

Posting Permissions

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