View Single Post
12-21-16, 12:32 PM   #5
briskman3000
A Flamescale Wyrmkin
 
briskman3000's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 108
I ended up not using the code that I had posted here, and instead changed up a bunch of things in the code using what you provided as a basis for how things are called and set, and from what I read from a few different sources.

I think I got the stats to calculate, as I am not getting any error output from the calculation lines ( was getting some nil errors because I had the table set up wrong and attempting to lookup values in a way that was impossible)

However, I am not getting any output into the tooltip anymore.


I've probably forgot some event that needs to be fired somewhere, but I don't see it.

Here is the code for the addon pulling the stats, converting them, and then attempting to output them to the tooltip:
Code:
local function getItemIdFromTooltip(self)
    local name, itemLink = self:GetItem();
    
    --Gets stats from item using itemLink - it's a table
    stats = GetItemStats(itemLink);

    --Gnor: pull individual stats from stats table since the way that it was being accomplished wouldn't allow for calculations to be done
    local rawmastery = stats["ITEM_MOD_MASTERY_RATING_SHORT"]
    local rawcrit = stats["ITEM_MOD_CRIT_RATING_SHORT"]
    local rawhaste = stats["ITEM_MOD_HASTE_RATING_SHORT"]
    local rawvers = stats["ITEM_MOD_VERSATILITY"]

    --convert raw stats into percentages so long as they are not nil
    --This seems to work, as I am not getting any error output
if rawcrit ~= nil
   then
       local pcrit = rawcrit / critamt
   else
   end

if rawhaste ~= nil
   then
       local phaste = rawhaste / hasteamt
   else
   end

if rawvers ~= nil
   then
       local pversin = rawvers / versinamt
       local pversout = rawvers / versoutamt
   else
   end

if rawmastery ~= nil
   then
       local pmastery = (rawmastery / masteryamt) * masterycf
   else
   end

--Convert percentages to strings
tostring(pcrit)
tostring(phaste)
tostring(pversin)
tostring(pversout)
tostring(pmastery)

--Send the converted stats to the tooltip if they are not nil
--This does not work atm
--temp see if they output to chat ... nope must be missing something

if pcrit ~= nil
   then
      GameTooltip:AddLine(pcrit .. "% Crit")
   else
   end

 if phaste ~= nil
   then
       GameTooltip:AddLine(phaste .. "% Haste")
   else
   end

 if pmastery ~= nil
   then
       GameTooltip:AddLine(pmastery .. "% Mastery")
   else
   end

if pversin ~= nil
   then
      GameTooltip:AddLine(pversin .. "%/" .. pversout .. "% Versatility")
   else
   end
end
GameTooltip:HookScript("OnTooltipSetItem", getItemIdFromTooltip);
  Reply With Quote