Simple iLevel

23 - Add LibDogTag-3.0 support

I use IceHud, which in turn uses LibDogTags-3.0 to show custom text. I would love to be able to show the item level, if known, of my target as part of my tags. This means adding a "tag" to LibDogTags, which I did through this code:

local tag = {
   code = function(unit)
      local ilvl = SIL:Cache(UnitGUID(unit), 'score')
      if type(ilvl) == "number" then
         return ilvl
      else
         return ''
      end
   end,
   arg = {
      'unit', 'string;undef', 'player'
   },
   ret = "number;string",
   events = "UNIT_INVENTORY_CHANGED#$unit;INSPECT_READY#$unit",
   doc = "Return the item level of unit (from Simple iLevel)",
   example = ('[ItemLevel] => "%d"; [ItemLevel] => ""'):format(552.1),
   category = "Characteristics"
}
LibStub("LibDogTag-3.0"):AddTag("Unit", "ItemLevel", tag)

It would be awesome to adopt that into your addon as an optional dependency / protected by "if there is no such library". I have tested that and it works correctly, at least for me.

Note: if you had a custom ever that fired with the unit, when the cache was updated, that would be super-convenient because it would avoid the possible race of hooking in to listen on those two events. That would avoid unnecessary work and ensure correct updates. I didn't look for an event like that in your code though.

Finally, if you don't want this in your code, but are willing to accept it externally, I will turn it into an addon myself -- having confirmation that the API I am using to query the item level out, and a custom event as indicated, would be super-helpful to make that integration work smoothly.

User When Change
slippycheeze Dec 25, 2013 at 00:44 UTC Changed description:
        'unit', 'string;undef', 'player'
     },
     ret = "number;string",
-    events = "UNIT_INVENTORY_CHANGED#$unit",
+    events = "UNIT_INVENTORY_CHANGED#$unit;INSPECT_READY#$unit",
     doc = "Return the item level of unit (from Simple iLevel)",
     example = ('[ItemLevel] => "%d"; [ItemLevel] => ""'):format(552.1),
     category = "Characteristics"
----------------------------------------
  </pre>

  It would be awesome to adopt that into your addon as an optional dependency / protected by "if there is no such library".  I have tested that and it works correctly, at least for me.
+
+ Note: if you had a custom ever that fired with the unit, when the cache was updated, that would be super-convenient because it would avoid the possible race of hooking in to listen on those two events.  That would avoid unnecessary work and ensure correct updates.  I didn't look for an event like that in your code though.
+
+ Finally, if you don't want this in your code, but are willing to accept it externally, I will turn it into an addon myself -- having confirmation that the API I am using to query the item level out, and a custom event as indicated, would be super-helpful to make that integration work smoothly.
slippycheeze Dec 25, 2013 at 00:27 UTC Changed description:
  I use IceHud, which in turn uses LibDogTags-3.0 to show custom text.  I would love to be able to show the item level, if known, of my target as part of my tags.  This means adding a "tag" to LibDogTags, which I did through this code:

- <code>
+ <pre>
  local tag = {
     code = function(unit)
        local ilvl = SIL:Cache(UnitGUID(unit), 'score')
----------------------------------------
     category = "Characteristics"
  }
  LibStub("LibDogTag-3.0"):AddTag("Unit", "ItemLevel", tag)
- </code>
+ </pre>

  It would be awesome to adopt that into your addon as an optional dependency / protected by "if there is no such library".  I have tested that and it works correctly, at least for me.
slippycheeze Dec 25, 2013 at 00:26 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

Facts

Last updated
Dec 25, 2013
Reported
Dec 25, 2013
Status
New - Issue has not had initial review yet.
Type
Patch - Source code patch for review
Priority
Medium - Normal priority.
Votes
0

Reported by

Possible assignees