WoW:API GetTradeSkillNumReagents: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
m (Move page script moved page API GetTradeSkillNumReagents to API GetTradeSkillNumReagents without leaving a redirect)
 
(5 intermediate revisions by 5 users not shown)
Line 1: Line 1:
  <center>'''GetTradeSkillNumReagents''' ''-Documentation by [[User:Goldark|Goldark]]-''</center>
{{wowapi}} __NOTOC__
Returns the number of distinct reagents required by the specified recipe.
  numReagents = GetTradeSkillNumReagents(tradeSkillRecipeId);


Returns the number of different reagents required by the specified recipe. Thus, if a recipe calls for 2 copper tubes, 1 malachite and 2 blasting powders, GetTradeSkillNumReagents would return 3. If it required 5 linen cloths, the result would be 1.
==Parameters==
===Arguments===
:;tradeSkillRecipeId : Integer - The id of the trade skill recipe.
===Returns===
:; reagentCount : Integer - The number of distinct reagents required to create the item.


Once you know how many different reagents you need, you can use [[API GetTradeSkillReagentInfo]] to find out how many of each one are required.


local numReagents = GetTradeSkillNumReagents(tradeSkillRecipeId);
==Example==
 
----
;''Arguments''
 
:(Number tradeSkillRecipeId)
 
:;tradeSkillRecipeId : The Id of the trade skill recipe
 
----
;''Returns''
 
: Integer reagentCount
 
:; reagentCount : The number of different reagents required to create the item.
 
 
----
;''Example''
  local numReagents = GetTradeSkillNumReagents(id);
  local numReagents = GetTradeSkillNumReagents(id);
  local totalReagents = 0;
  local totalReagents = 0;
Line 30: Line 17:
   totalReagents = totalReagents + reagentCount;
   totalReagents = totalReagents + reagentCount;
  end;
  end;
===Result===
Calculates the total number of items required by the recipe.


==Notes==
If a recipe calls for 2 copper tubes, 1 malachite and 2 blasting powders, GetTradeSkillNumReagents would return 3. If it required 5 linen cloths, the result would be 1.


----
Once you know how many distinct reagents you need, you can use [[API GetTradeSkillReagentInfo|GetTradeSkillReagentInfo]] to find out how many of each one are required.
{{Template:WoW API}}
 
[[Category:API TradeSkill Functions|GetTradeSkillNumReagents]]

Latest revision as of 04:46, 15 August 2023

WoW API < GetTradeSkillNumReagents

Returns the number of distinct reagents required by the specified recipe.

numReagents = GetTradeSkillNumReagents(tradeSkillRecipeId);

Parameters[edit]

Arguments[edit]

tradeSkillRecipeId
Integer - The id of the trade skill recipe.

Returns[edit]

reagentCount
Integer - The number of distinct reagents required to create the item.


Example[edit]

local numReagents = GetTradeSkillNumReagents(id);
local totalReagents = 0;
for i=1, numReagents, 1 do
  local reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(id, i);
  totalReagents = totalReagents + reagentCount;
end;

Result[edit]

Calculates the total number of items required by the recipe.

Notes[edit]

If a recipe calls for 2 copper tubes, 1 malachite and 2 blasting powders, GetTradeSkillNumReagents would return 3. If it required 5 linen cloths, the result would be 1.

Once you know how many distinct reagents you need, you can use GetTradeSkillReagentInfo to find out how many of each one are required.