View Single Post
11-22-22, 04:09 PM   #1
Arcilux
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2015
Posts: 4
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?
  Reply With Quote