Thread Tools Display Modes
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
11-22-22, 04:17 PM   #2
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 133
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
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }
  Reply With Quote
11-22-22, 04:44 PM   #3
Arcilux
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2015
Posts: 4
Thanks Xruptor, that looks perfect.
  Reply With Quote
11-27-22, 03:26 AM   #4
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
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.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Getting Item Repair Cost with new Tooltip Functions

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off