Thread Tools Display Modes
07/13/24, 02:57 PM   #1
tomstock
AddOn Author - Click to view addons
Join Date: Feb 2022
Posts: 6
Question Recipe ItemLink from Result ItemLink

For my Furnishing Recipe Collector addon, I have a need to get the recipe item link from the result item link.

I can't seem to get this working:
https://wiki.esoui.com/Select_a_recipe_in_recipe_list

I'm using the following functions, which seems like they should work, but they are not giving me the itemLink for the recipe, they are giving me the itemLink for the result item:

local craftingStationType, recipeListIndex,recipeIndex = GetRecipeInfoFromItemId(vItemLinkId)
local known_, name_, numIngredients_, provisionerLevelReq_, qualityReq_, specialIngredientType_, requiredCraftingStationType_, resultItemId_ GetRecipeInfo(recipeListIndex,recipeIndex)

I then tried figuring out how to iterate over ingredients, to see if the recipe was an ingredient, and I can't seem to find the correct way to iterate over the ingredients:

local link = GetRecipeIngredientItemLink(recipeListIndex, recipeIndex, i, LINK_STYLE_BRACKETS)
  Reply With Quote
07/13/24, 03:08 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,098
Code:
--- @param recipeListIndex luaindex
--- @param recipeIndex luaindex
--- @param linkStyle [LinkStyle|#LinkStyle]
--- @return link string
function GetRecipeResultItemLink(recipeListIndex, recipeIndex, linkStyle) end
This returns the itemlink for the results, e.g. the food.

And you are searching the itemlink of the recipe for that food then?
I'm not sure if this is possible, maybe someone else knows.

Perhaps this returns the itemlink you search then:
Code:
--- @param itemLink string
--- @param linkStyle [LinkStyle|#LinkStyle]
--- @return link string
function GetItemLinkRecipeResultItemLink(itemLink, linkStyle) end

Last edited by Baertram : 07/13/24 at 03:15 PM.
  Reply With Quote
07/13/24, 09:04 PM   #3
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 411
This is not possible to do through the API. You'll need to maintain a lookup list, or point to one in another addon. There are some addons which already do this. MM has a list, as well as LLC (which I copied from MM so talk to sharlikran if you want to use it too)
  Reply With Quote
Yesterday, 11:44 AM   #4
tomstock
AddOn Author - Click to view addons
Join Date: Feb 2022
Posts: 6
If a static list is required by multiple addons, seems like it should be made into a library. Thank you both for your feedback.
  Reply With Quote
Yesterday, 12:37 PM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,098
https://www.esoui.com/downloads/info3927-LibRecipe.html

Sharlikran read/heard you
  Reply With Quote
Yesterday, 12:41 PM   #6
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 685
I would prefer that people would not essentially borrow or copy MM code for what it does to get the number of ingredients for the craft cost of items.

I had mentioned to Dolgubon that it would be better to use a library I was working on for CraftStore and that I could use with MM, TTCCompanion, and possibly WW. However, at the time he didn't want to use another dependency so I didn't bother uploading it.

https://www.esoui.com/downloads/info3927-LibRecipe.html

Once it's approved by the admins just use that Library.

Lua Code:
  1. LibRecipe:GetRecipeItemLink(itemLink)

Pass the furniture item to that link and it will provide the recipe.

Last edited by Sharlikran : Yesterday at 12:45 PM.
  Reply With Quote
Yesterday, 12:50 PM   #7
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 685
Originally Posted by Dolgubon View Post
This is not possible to do through the API. You'll need to maintain a lookup list, or point to one in another addon. There are some addons which already do this. MM has a list, as well as LLC (which I copied from MM so talk to sharlikran if you want to use it too)
I didn't mind if you used the information but it would still be better to use the library I had told you I had made already. Simply for the reason that in your Provisioning.lua file, the list is outdated. What I have in MM and LibRecipe is current as of U42.

You are missing 143 Recipes.

Last edited by Sharlikran : Yesterday at 12:52 PM.
  Reply With Quote
Yesterday, 01:04 PM   #8
tomstock
AddOn Author - Click to view addons
Join Date: Feb 2022
Posts: 6
You are awesome Sharlikran!!!! Thanks
  Reply With Quote
Yesterday, 01:51 PM   #9
tomstock
AddOn Author - Click to view addons
Join Date: Feb 2022
Posts: 6
Worked perfectly. Just posted a new version of the Furnishing Recipe Collector with the optional LibRecipe integration.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Recipe ItemLink from Result ItemLink


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