WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Getting Item Repair Cost with new Tooltip Functions (https://www.wowinterface.com/forums/showthread.php?t=59366)

Arcilux 11-22-22 04:09 PM

Getting Item Repair Cost with new Tooltip Functions
 
In my addon I would get the total cost to repair all of the player's gear by running:

Code:

repairTooltip = repairTooltip or CreateFrame("GameTooltip");
        local slots = {'HEADSLOT', 'NECKSLOT', 'SHOULDERSLOT',
        'BACKSLOT', 'CHESTSLOT', 'WRISTSLOT', 'HANDSSLOT',
        'WAISTSLOT', 'LEGSSLOT', 'FEETSLOT', 'FINGER0SLOT',
        'FINGER1SLOT', 'TRINKET0SLOT', 'TRINKET1SLOT',
        'MAINHANDSLOT', 'SECONDARYHANDSLOT'};
        local totalRepairCost = 0;
        for i, slot in ipairs(slots) do
                repairTooltip:ClearLines();
                local slotId, _ = GetInventorySlotInfo(slot);
                local hasItem, _, repairCost = repairTooltip:SetInventoryItem("player", slotId);
                if ((hasItem) and (repairCost) and (repairCost > 0)) then
                        totalRepairCost = totalRepairCost + repairCost;
                end
        end
        return totalRepairCost;

With 10.0.2, GameTooltip does not expose the function calls anymore, but I cannot figure out how to get the repair cost using the new C_TooltipInfo calls. I tried doing a dump of C_TooltipInfo.GetInventoryItem("player", slotId), but it's a bunch of JSON and none of the fields appear to represent repair cost.

Am I missing something with the tooltip scanning path? Or is there an easier way to get repair cost when not at a repair vendor?

Xruptor 11-22-22 04:17 PM

Take a look at my addon on the updated method to grab the repairCosts. I had the same issue when I went to update the addon for DragonFlight.

https://www.wowinterface.com/downloa...urability.html

Arcilux 11-22-22 04:44 PM

Thanks Xruptor, that looks perfect.

gmarco 11-27-22 03:26 AM

Hi all,

I am using a different and simplest approach for my autorepair.


Lua Code:
  1. local cost = GetRepairAllCost()
  2.         if cost > 0 and CanMerchantRepair() and GMDURABILITY_CFG["AUTOREPAIR"] then
  3.                    
  4.             if CanWithdrawGuildBankMoney() and CanGuildBankRepair() and GMDURABILITY_CFG["GUILDREPAIR"] == true then
  5.                 RepairAllItems(1)
  6.                 print(prgname .. ": " .. L["repair with guild funds"] .. " " .. GetCoinTextureString(cost))
  7.             else
  8.                 if mymoney >= cost then
  9.                     RepairAllItems()
  10.                     print(prgname .. ": " .. L["repair"] .. " " .. GetCoinTextureString(cost))
  11.                 else
  12.                     print(prgname .. ": " .. L["no repair, need more money"])
  13.                 end
  14.             end
  15.         end

but now you have make me dubious if it is correct or no :)

At the end it prints the repair cost :



and it seems to me correct.


All times are GMT -6. The time now is 12:10 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI