Thread Tools Display Modes
08-31-19, 08:51 AM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
WoW Classic Professions

I could use some help with getting data for professions.

I've been hunting around and can not seem to find the right way to get this to work in classic (that is if it is even possible)

Here is the "Retail" code:
Code:
		local proPlugin = CreateFrame('Button', nil, Datapanel)
		proPlugin:RegisterEvent('PLAYER_ENTERING_WORLD')
		proPlugin:SetFrameStrata('BACKGROUND')
		proPlugin:SetFrameLevel(3)
		proPlugin:EnableMouse(true)
		proPlugin.tooltip = false

		local Text = proPlugin:CreateFontString(nil, 'OVERLAY')
		Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
		PlacePlugin(db.pro, Text)

		local function Update(self)
			Text:SetFormattedText(hexa.."Professions"..hexb)
			self:SetAllPoints(Text)
		end

		proPlugin:SetScript('OnEnter', function()		
			local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
			GameTooltip:SetOwner(panel, anchor, xoff, yoff)
			GameTooltip:ClearLines()
			GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Professions")
			GameTooltip:AddLine' '
			for i = 1, select("#", GetProfessions()) do
				local v = select(i, GetProfessions());
				if v ~= nil then
					local name, texture, rank, maxRank = GetProfessionInfo(v)
					GameTooltip:AddDoubleLine(name, rank..' / '..maxRank,.75,.9,1,.3,1,.3)
				end
			end
			GameTooltip:AddLine' '
			GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Profession #1")
			GameTooltip:AddLine("|cffeda55fMiddle Click|r to Open Spell Book")
			GameTooltip:AddLine("|cffeda55fRight Click|r to Open Profession #2")
			
			GameTooltip:Show()
		end)


		proPlugin:SetScript("OnClick",function(self,btn)
			local prof1, prof2 = GetProfessions()
			if btn == "LeftButton" then
				if prof1 then
					if(GetProfessionInfo(prof1) == ('Skinning')) then
						CastSpellByName("Skinning Skills")
					elseif(GetProfessionInfo(prof1) == ('Mining')) then
						CastSpellByName("Mining Skills")
					elseif(GetProfessionInfo(prof1) == ('Herbalism')) then
						CastSpellByName("Herbalism Skills")					
					else	
						CastSpellByName((GetProfessionInfo(prof1)))
					end
				else
					print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
				end
			elseif btn == 'MiddleButton' then
				ToggleSpellBook(BOOKTYPE_PROFESSION)	
			elseif btn == "RightButton" then
				if prof2 then
					if(GetProfessionInfo(prof2) == ('Skinning')) then
						CastSpellByName("Skinning Skills")
					elseif(GetProfessionInfo(prof2) == ('Mining')) then
						CastSpellByName("Mining Skills")
					elseif(GetProfessionInfo(prof2) == ('Herbalism')) then
						CastSpellByName("Herbalism Skills")						
					else
						CastSpellByName((GetProfessionInfo(prof2)))
					end
				else
					print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
				end
			end
		end)


		proPlugin:RegisterForClicks("AnyUp")
		proPlugin:SetScript('OnUpdate', Update)
		proPlugin:SetScript('OnLeave', function() GameTooltip:Hide() end)
Thanks for any help with this.
Coke
  Reply With Quote
01-22-20, 08:18 AM   #2
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Ok so I am able to get ALL the skill listed how can I break them down into professions?

Here is the code that works and the pic to go with it.
Lua Code:
  1. for skillIndex = 1, GetNumSkillLines() do
  2.     local skillName, isHeader, _, skillRank, _, _, skillMaxRank, _, _, _, _, _, _ = GetSkillLineInfo(skillIndex)
  3.     if not isHeader then
  4.         GameTooltip:AddDoubleLine(skillName, skillRank..' / '..skillMaxRank,.75,.9,1,.3,1,.3)
  5.     end
  6. end



So if any of you mad coders can help me out with breaking the list down that would be great.

Last edited by cokedrivers : 01-22-20 at 09:39 AM.
  Reply With Quote
01-22-20, 02:06 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Does the IsAbandonable return work? (8th in the list)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
01-22-20, 06:19 PM   #4
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Seerah View Post
Does the IsAbandonable return work? (8th in the list)
Yes this works but it only return the 2 Professions not the secondary skills.

so I've been playing around with it and almost have it where I want it.

Its sloppy but almost does the trick.
Code:
GameTooltip:AddLine("Professions")
for skillIndex = 1, GetNumSkillLines() do
	local skillName, isHeader, _, skillRank, _, _, skillMaxRank, isAbandonable, _, _, _, _, _ = GetSkillLineInfo(skillIndex)
	if isAbandonable then
		GameTooltip:AddDoubleLine(skillName, skillRank..' / '..skillMaxRank,.75,.9,1,.3,1,.3)
	end
end

GameTooltip:AddLine(" ")
GameTooltip:AddLine("Secondary Skills")
for skillIndex = 1, GetNumSkillLines() do
	local skillName, isHeader, _, skillRank, _, _, skillMaxRank, isAbandonable, _, _, _, _, _ = GetSkillLineInfo(skillIndex)
	if skillName == "Cooking" then
		GameTooltip:AddDoubleLine("Cooking", skillRank..' / '..skillMaxRank,.75,.9,1,.3,1,.3)
	end
	if skillName == "First Aid" then
		GameTooltip:AddDoubleLine("First Aid", skillRank..' / '..skillMaxRank,.75,.9,1,.3,1,.3)
	end
	if skillName == "Fishing" then
		GameTooltip:AddDoubleLine("Fishing", skillRank..' / '..skillMaxRank,.75,.9,1,.3,1,.3)
	end
end
	
GameTooltip:AddLine(" ")
GameTooltip:AddLine("Skills")
for skillIndex = 1, GetNumSkillLines() do
	local skillName, isHeader, _, skillRank, _, _, skillMaxRank, isAbandonable, _, _, _, _, _ = GetSkillLineInfo(skillIndex)			
	if not isHeader and not isAbandonable then
		GameTooltip:AddDoubleLine(skillName, skillRank..' / '..skillMaxRank,.75,.9,1,.3,1,.3)
	end

end
Here is the screenshot:


Now if I can just figure out how to remove the Secondary skills from the bottom list it would be perfect.

Thanks again for the help.
  Reply With Quote
01-23-20, 01:39 AM   #5
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Classic's skills tab is always in the same order: Class, Primary, Secondary, Weapon, Armor, and Language. Using the header text, the SKILLS global string, and some local tables:

Lua Code:
  1. local section, primary, secondary, other = 0, {}, {}, {}
  2.  
  3. for i = 1, GetNumSkillLines() do
  4.     local name, header, _, rank, _, _, max = GetSkillLineInfo(i)
  5.     if header then
  6.         section = section + 1
  7.         if section == 2 then
  8.             primary.n = name
  9.         elseif section == 3 then
  10.             secondary.n = name
  11.         end
  12.     else
  13.         tinsert( section == 2 and primary or section == 3 and secondary or other, {name,rank..' / '..max,.75,.9,1,.3,1,.3} )
  14.     end
  15. end
  16.  
  17. GameTooltip:AddLine(primary.n)
  18. for i = 1, #primary do
  19.     GameTooltip:AddDoubleLine( unpack( primary[i] ) )
  20. end
  21.  
  22. GameTooltip:AddLine(" ")
  23. GameTooltip:AddLine(secondary.n)
  24. for i = 1, #secondary do
  25.     GameTooltip:AddDoubleLine( unpack( secondary[i] ) )
  26. end
  27.  
  28. GameTooltip:AddLine(" ")
  29. GameTooltip:AddLine(SKILLS)
  30. for i = 1, #other do
  31.     GameTooltip:AddDoubleLine( unpack( other[i] ) )
  32. end
  Reply With Quote
01-23-20, 07:41 AM   #6
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Kanegasi View Post
Classic's skills tab is always in the same order: Class, Primary, Secondary, Weapon, Armor, and Language. Using the header text, the SKILLS global string, and some local tables:

Lua Code:
  1. local section, primary, secondary, other = 0, {}, {}, {}
  2.  
  3. for i = 1, GetNumSkillLines() do
  4.     local name, header, _, rank, _, _, max = GetSkillLineInfo(i)
  5.     if header then
  6.         section = section + 1
  7.         if section == 2 then
  8.             primary.n = name
  9.         elseif section == 3 then
  10.             secondary.n = name
  11.         end
  12.     else
  13.         tinsert( section == 2 and primary or section == 3 and secondary or other, {name,rank..' / '..max,.75,.9,1,.3,1,.3} )
  14.     end
  15. end
  16.  
  17. GameTooltip:AddLine(primary.n)
  18. for i = 1, #primary do
  19.     GameTooltip:AddDoubleLine( unpack( primary[i] ) )
  20. end
  21.  
  22. GameTooltip:AddLine(" ")
  23. GameTooltip:AddLine(secondary.n)
  24. for i = 1, #secondary do
  25.     GameTooltip:AddDoubleLine( unpack( secondary[i] ) )
  26. end
  27.  
  28. GameTooltip:AddLine(" ")
  29. GameTooltip:AddLine(SKILLS)
  30. for i = 1, #other do
  31.     GameTooltip:AddDoubleLine( unpack( other[i] ) )
  32. end
Thank You very much @Kanegasi and @Seerah for taking the time to help me with this.

With using @Kanegasi's main lay out I was able to get the perfect setup for my tooltip for my databar.

Here is the code in its final stage:
Code:
local section, primary, secondary, weapons, other = 0, {}, {}, {}, {}
 
for i = 1, GetNumSkillLines() do
	local skillName, isHeader, _, skillRank, _, _, skillMaxRank = GetSkillLineInfo(i)
	if isHeader then
		section = section + 1
		if section == 2 then
			primary.n = skillName
		elseif section == 3 then
			secondary.n = skillName
		elseif section == 4 then
			weapons.n = skillName
		end
	else
		tinsert( section == 2 and primary or section == 3 and secondary or section == 4 and weapons or other,  {skillName,skillRank..' / '..skillMaxRank,.75,.9,1,.3,1,.3} )
	end
end
 
GameTooltip:AddLine(primary.n)
for i = 1, #primary do
	GameTooltip:AddDoubleLine( unpack( primary[i] ) )
end
 
GameTooltip:AddLine(" ")
GameTooltip:AddLine(secondary.n)
for i = 1, #secondary do
	GameTooltip:AddDoubleLine( unpack( secondary[i] ) )
end
 
GameTooltip:AddLine(" ")
GameTooltip:AddLine(weapons.n)
for i = 1, #weapons do
	GameTooltip:AddDoubleLine( unpack( weapons[i] ) )
end

GameTooltip:Show()
end)
and here is the screenshot of how it turned out:


Again thanks for the help.

Coke
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » WoW Classic Professions

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