Quantcast Make TSM show craft price and profit on all craftable items. - WoWInterface
Thread Tools Display Modes
12-06-19, 11:43 PM   #1
hasnogaems
A Wyrmkin Dreamwalker
 
hasnogaems's Avatar
Join Date: Apr 2016
Posts: 57
Make TSM show craft price and profit on all craftable items.

In wow classic. I'm trying to edit file that I think must regulate its behaviour, so far my tinkering made TSM crafting tab completely dissapear from tooltips.
Default behaviour is showing crafting tab only for learned recipes.
https://imgur.com/a/v9w5bxw

Here is the code:
Code:
-- ------------------------------------------------------------------------------ --
--                                TradeSkillMaster                                --
--                http://www.curse.com/addons/wow/tradeskill-master               --
--                                                                                --
--             A TradeSkillMaster Addon (http://tradeskillmaster.com)             --
--    All Rights Reserved* - Detailed license information included with addon.    --
-- ------------------------------------------------------------------------------ --

local _, TSM = ...
local Crafting = TSM.Tooltip:NewPackage("Crafting")
local L = TSM.L
local private = {}
local DEFAULTS = {
	craftingCost = true,
	matPrice = false,
	detailedMats = false,
}



-- ============================================================================
-- Module Functions
-- ============================================================================

function Crafting.OnInitialize()
	TSM.Tooltip.Register("Crafting", DEFAULTS, private.LoadTooltip)
end



-- ============================================================================
-- Private Helper Functions
-- ============================================================================

function private.LoadTooltip(tooltip, itemString, options)
	itemString = TSMAPI_FOUR.Item.ToBaseItemString(itemString)

	if TSM.Crafting.CanCraftItem(itemString) and options.craftingCost then
		local cost, spellId = TSM.Crafting.Cost.GetLowestCostByItem(itemString)
		if cost then
			local buyout = TSM.Crafting.Cost.GetCraftedItemValue(itemString)
			local profit = buyout and (buyout - cost) or nil

			local costText = cost and tooltip:FormatMoney(cost) or "|cffffffff---|r"
			local profitColor = (profit or 0) < 0 and "|cffff0000" or "|cff00ff00"
			local profitText = profit and tooltip:FormatMoney(profit, profitColor) or "|cffffffff---|r"
			tooltip:AddLine(L["Crafting Cost"], format(L["%s (%s profit)"], costText, profitText))

			if options.detailedMats then
				tooltip:StartSection()
				local numResult = TSM.Crafting.GetNumResult(spellId)
				for _, matItemString, matQuantity in TSM.Crafting.MatIterator(spellId) do
					local name = TSMAPI_FOUR.Item.GetName(matItemString)
					local matCost = TSM.Crafting.Cost.GetMatCost(matItemString)
					local quality = TSMAPI_FOUR.Item.GetQuality(matItemString)
					if name and matCost and quality then
						tooltip:AddSubItemValueLine(matItemString, matCost, matQuantity / numResult)
					end
				end
				tooltip:EndSection()
			end
		end
	end

	-- add mat price
	if options.matPrice then
		local matCost = TSM.Crafting.Cost.GetMatCost(itemString)
		if matCost then
			tooltip:AddItemValueLine(L["Mat Cost"], matCost)
		end
	end
end
I highlighted the line that I want to be displayed on every craftable item, not only on which I can craft myself.

Last edited by hasnogaems : 12-16-19 at 11:52 PM.
  Reply With Quote
12-07-19, 11:55 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,093
Your best bet is post a pastebin or link this thread to the TSM/Woweconomy Discord server. Use the #Classic-Support channel.

https://discord.gg/FJ4877H

http://support.tradeskillmaster.com/ to get the Discord link again. It's at the bottom middle. The TSM devs watch for support there.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Make TSM show craft price and profit on all craftable items.

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