Quantcast [Classic] Convert recipe item name to spellID - WoWInterface
Thread Tools Display Modes
09-06-19, 09:03 PM   #1
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
[Classic] Convert recipe item name to spellID

In BfA, you can do the following with a crafting recipe spell name, and get the related spellID:

Code:
local spellLink = GetSpellLink(spellName);
    if spellLink then
        return tonumber(spellLink:match("spell:(%d+)"));
    end
However in Classic this just returns an empty string in the spellLink variable.

I used to use GetTradeSkillLink with an index to get this information, but that function has been removed.

Does anyone know the correct way to get the spellID from a crafted name with WoW Classic, such as:
  • Smelt Bronze
  • Murloc Fin Soup
  • Heavy Linen Bandage

Thanks!
  Reply With Quote
09-06-19, 11:48 PM   #2
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
I tried using GetItemInfo and parsing the itemLink, but it doesn't work for everything. For example, it works for "Murlock Fin Soup" but not for "Clam Chowder" :/ There's no itemLink returned in the latter case.
  Reply With Quote
09-07-19, 11:08 AM   #3
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
I think I found a different way to do what I need, using the new C_TradeSkillUI.GetAllRecipeIDs() function. Will test.
  Reply With Quote
09-07-19, 05:12 PM   #4
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
Foiled again, as that API doesn't exist in Classic... so back to the original question. How in the world do I map known recipes to an ID?
  Reply With Quote
09-07-19, 05:42 PM   #5
LudiusMaximus
A Flamescale Wyrmkin
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 116
I do not quite understand.

In the title you are asking about recipes, but in the post you are also asking about "Smelt Bronze" and "Heavy Linen Bandage" which are *not* taught by recipes.

If you want to get the spellID from a recipe that teaches it, you can use this lib: LibRecipes-2.0
  Reply With Quote
09-07-19, 06:50 PM   #6
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
Originally Posted by LudiusMaximus View Post
I do not quite understand.

In the title you are asking about recipes, but in the post you are also asking about "Smelt Bronze" and "Heavy Linen Bandage" which are *not* taught by recipes.

If you want to get the spellID from a recipe that teaches it, you can use this lib: LibRecipes-2.0
a) LibRecipes does not appear to have a version for Classic, so it's out.

b) Its API takes an ID. An ID I don't have, because the entire point of this post is me asking how do I take the TEXTUAL NAME returned by GetTradeSkillInfo and get it CONVERTED into an ID.
  Reply With Quote
09-07-19, 08:21 PM   #7
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
Originally Posted by kernighan View Post
a) LibRecipes does not appear to have a version for Classic, so it's out.

b) Its API takes an ID. An ID I don't have, because the entire point of this post is me asking how do I take the TEXTUAL NAME returned by GetTradeSkillInfo and get it CONVERTED into an ID.
Well, I figured a way to get it converted to the itemID using GetTradeSkillItemLink which still exists, which I can then use my internal DB to map to the spellID, I believe. So I think I have a working solution.

Generally, I think libRecipes could work in this case IF it had a classic version, since I can get the itemID now.
  Reply With Quote
09-08-19, 02:13 AM   #8
LudiusMaximus
A Flamescale Wyrmkin
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 116
Originally Posted by kernighan View Post
Generally, I think libRecipes could work in this case IF it had a classic version, since I can get the itemID now.
It does not have an explicit version for classic. But as far as I could tell the recipe IDs of the vanilla recipes are still the same as they are today. So you can simply use libRecipes in classic with the only disadvantage that the database also contains all the recipes that do yet exist in classic. But that is nothing the user would notice anyway.
  Reply With Quote
09-08-19, 02:48 AM   #9
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
Originally Posted by LudiusMaximus View Post
It does not have an explicit version for classic. But as far as I could tell the recipe IDs of the vanilla recipes are still the same as they are today. So you can simply use libRecipes in classic with the only disadvantage that the database also contains all the recipes that do yet exist in classic. But that is nothing the user would notice anyway.
There are recipes that exist in Classic that don't exist in later wow releases, such as the First Aid, Cooking, and Fishing books necessary to get from level 150 to 225. Also the mageweave bandages books.I can see if they exist in libRecipe.

Also, I already have to maintain a Classic specific version because some vendors that sell recipes in Classic don't exist and/or don't sell the recipes in later WoW releases. So I'm pretty sure there would need to be a Classic specific version of the library for it to be useful.
  Reply With Quote
09-10-19, 02:53 AM   #10
wildcard25
A Fallenroot Satyr
 
wildcard25's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 29
Code:
spellID = select(7, GetSpellInfo(spellName))
Can return nil if not cached yet.

edit: Whoops, pretty sure this doesn't work with Tradeskills. It's been a few years, but I think we had to build our own lookup table in Gnomeworks for recipeIDs.

Last edited by wildcard25 : 09-10-19 at 03:01 AM.
  Reply With Quote
09-10-19, 08:10 AM   #11
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
Originally Posted by LudiusMaximus View Post
It does not have an explicit version for classic. But as far as I could tell the recipe IDs of the vanilla recipes are still the same as they are today. So you can simply use libRecipes in classic with the only disadvantage that the database also contains all the recipes that do yet exist in classic. But that is nothing the user would notice anyway.
Originally Posted by wildcard25 View Post
Code:
spellID = select(7, GetSpellInfo(spellName))
Can return nil if not cached yet.

edit: Whoops, pretty sure this doesn't work with Tradeskills. It's been a few years, but I think we had to build our own lookup table in Gnomeworks for recipeIDs.
Yeah, that's what I've done so far for my addon (build a table by hand). Which really ... sucks. But it "works" :P Maybe we should all band together and create a common library for this data?

What I have so far can be found at https://bitbucket.org/yunohu/reciper...ic/src/master/

Specifically the RecipeData.lua file and the RegionData.lua file.
  Reply With Quote
09-13-19, 07:27 PM   #12
bsmorgan
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 184
I'm working on the tradeskill addon Skillet-Classic, a port of Skillet from retail, and I find it amazing that I can get the names of tradeskills and I can "DoTradeSkill(name, count)" which triggers a bunch of events which contain the spellID. I can "name = GetSpellInfo(spellID)" but given the name, I can't get the spellID because all the functions that would do so don't exist in Classic.

Skillet (the retail version) is locale agnostic because it uses numeric spellIDs. I had to bastardize Skillet-Classic to use the name as the key instead. This blew any chance of a common set of source files.
  Reply With Quote
09-14-19, 09:10 AM   #13
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
Originally Posted by bsmorgan View Post
I'm working on the tradeskill addon Skillet-Classic, a port of Skillet from retail, and I find it amazing that I can get the names of tradeskills and I can "DoTradeSkill(name, count)" which triggers a bunch of events which contain the spellID. I can "name = GetSpellInfo(spellID)" but given the name, I can't get the spellID because all the functions that would do so don't exist in Classic.

Skillet (the retail version) is locale agnostic because it uses numeric spellIDs. I had to bastardize Skillet-Classic to use the name as the key instead. This blew any chance of a common set of source files.


I ended up indexing on itemID

Code:
    for i = 1, GetNumTradeSkills() do
      local recipe, hdr = GetTradeSkillInfo(i)
      if (recipe and hdr ~= "header") then
        local itemLink = GetTradeSkillItemLink(i)
        local itemID = itemLink:match("item:(%d+)")
        if(itemID) then
But I still have to create a database to map those to spellIDs. Very annoying.
  Reply With Quote
09-15-19, 10:50 AM   #14
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
Originally Posted by bsmorgan View Post
.
Skillet (the retail version) is locale agnostic because it uses numeric spellIDs. I had to bastardize Skillet-Classic to use the name as the key instead. This blew any chance of a common set of source files.
So I noticed Skillet isn't working with Enchanting. I was having the same problem. I found through some digging that Enchanting has been reverted to the old "Craft" API. I've updated my itemID fetching to be a function as follows:

Code:
function RecipeRadar_SkillDB_GetItemLink(prof_type, index)
  local itemLink, itemID

  if (prof_type == "trade") then
    itemLink = GetTradeSkillItemLink(index)
    itemID = itemLink:match("item:(%d+)")
  elseif (prof_type == "craft") then
    itemLink = GetCraftItemLink(index)
    itemID = itemLink:match("enchant:(%d+)")
  end

  return tonumber(itemID)

end
  Reply With Quote
09-15-19, 11:23 AM   #15
bsmorgan
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 184
Originally Posted by kernighan View Post
So I noticed Skillet isn't working with Enchanting.
By Skillet i assume you mean Skillet-Classic and there are more problems than just itemIDs. Blizzard won't let me replace the Enchanting frame. Other professions trigger the event TRADE_SKILL_SHOW or can be opened with CastSpellByName(name) but Enchanting doesn't work that way.

I'll have to find documentation (if it exists) for the Craft* API and see if that helps any.
  Reply With Quote
09-15-19, 02:14 PM   #16
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,076
Do either of these Load on Demand Blizzard addons load with Enchanting?
  • Blizzard_TradeSkillUI
  • Blizzard_CraftUI
If at least one does, you can get the name of the Enchanting frame, then hide it, and replace with your own frame.
  Reply With Quote
09-15-19, 04:27 PM   #17
bsmorgan
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 184
It's worse than that. To populate my own frame I use:

Code:
numSkills = GetNumTradeSkills()
for i = 1, numSkills do
    local skillName, skillType, numAvailable, isExpanded = GetTradeSkillInfo(i)
...
and Enchanting doesn't return anything for those two API calls. If there are similar API calls for the CraftUI then I guess I could "special case" Enchanting (and maybe Poisons for Rogues).

I got enough bugs to chase out of Skillet-Classic as it is so I'll have to defer introducing even more bugs for now.
  Reply With Quote
09-16-19, 09:35 AM   #18
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
Originally Posted by bsmorgan View Post
It's worse than that. To populate my own frame I use:
See the issue I filed here: https://www.wowace.com/projects/skil...ssic/issues/16
  Reply With Quote
09-16-19, 10:11 AM   #19
kernighan
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 45
Originally Posted by bsmorgan View Post
I got enough bugs to chase out of Skillet-Classic as it is so I'll have to defer introducing even more bugs for now.
Have you seen the issue where doing these calls makes profession windows open? Like I see it with Tailoring and Blacksmithing on the trade skills side, and with Enchanting on the crafting skill side.
  Reply With Quote

WoWInterface » Classic - AddOns, Compliations, Macros » Classic - AddOn Help/Support » [Classic] Convert recipe item name to spellID

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