WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Classic - AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=179)
-   -   [Classic] Convert recipe item name to spellID (https://www.wowinterface.com/forums/showthread.php?t=57437)

kernighan 09-06-19 09:03 PM

[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!

kernighan 09-06-19 11:48 PM

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.

kernighan 09-07-19 11:08 AM

I think I found a different way to do what I need, using the new C_TradeSkillUI.GetAllRecipeIDs() function. Will test.

kernighan 09-07-19 05:12 PM

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?

LudiusMaximus 09-07-19 05:42 PM

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

kernighan 09-07-19 06:50 PM

Quote:

Originally Posted by LudiusMaximus (Post 333643)
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.

kernighan 09-07-19 08:21 PM

Quote:

Originally Posted by kernighan (Post 333644)
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.

LudiusMaximus 09-08-19 02:13 AM

Quote:

Originally Posted by kernighan (Post 333646)
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.

kernighan 09-08-19 02:48 AM

Quote:

Originally Posted by LudiusMaximus (Post 333649)
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.

wildcard25 09-10-19 02:53 AM

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.

kernighan 09-10-19 08:10 AM

Quote:

Originally Posted by LudiusMaximus (Post 333649)
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.

Quote:

Originally Posted by wildcard25 (Post 333681)
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.

bsmorgan 09-13-19 07:27 PM

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.

kernighan 09-14-19 09:10 AM

Quote:

Originally Posted by bsmorgan (Post 333723)
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.

kernighan 09-15-19 10:50 AM

Quote:

Originally Posted by bsmorgan (Post 333723)
.
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


bsmorgan 09-15-19 11:23 AM

Quote:

Originally Posted by kernighan (Post 333761)
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.

myrroddin 09-15-19 02:14 PM

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.

bsmorgan 09-15-19 04:27 PM

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.

kernighan 09-16-19 09:35 AM

Quote:

Originally Posted by bsmorgan (Post 333775)
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

kernighan 09-16-19 10:11 AM

Quote:

Originally Posted by bsmorgan (Post 333775)
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.


All times are GMT -6. The time now is 09:23 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI