API:GetCraftingData
From RoR Wiki
UI Lua API · Crafting functions
Version: WAR 1.4.8
Returns the items currently placed in the crafting window of a trade skill.
craftingItems = GetCraftingData(tradeSkill)
Arguments
- tradeSkill
number– AGameData.TradeSkillsvalue. The stock UI usesAPOTHECARY(4) andTALISMAN(5).
Returns
- craftingItems
table– Array of 8 item data tables, indexed by crafting slot from 0 to 7.
Details
- The indexes start at 0, not 1.
ipairsskips entry 0; use a numericforloop from 0 as the stock UI does. - All 8 entries are always present. A crafting slot without an item gets a table with default values (
id0). - Nothing is returned for trade skill 0 or 7. Other values are not range-checked, so only pass real trade skill values. Nothing is returned either if there is no player object or the Lua state is not available.
- The stock crafting windows call it from their crafting status update handlers, together with GetCraftingBackPackSlots.
- Exactly one argument must be passed.
Errors
None besides the generic Invalid Parameters message when the argument is missing or not a number.
Example
From default/ea_craftingwindow/source/talismanmakingwindow.lua:
function TalismanMakingWindow.UpdateCraftingStatus( updatedIngredients )
...
local craftingData = GetCraftingData( GameData.TradeSkills.TALISMAN )
local backpackSlots = GetCraftingBackPackSlots( GameData.TradeSkills.TALISMAN )
...
for index = 0, TalismanMakingWindow.maxResources
do
if( not backpackSlots[index] )
then
break
end
local backpackSlot = backpackSlots[index].slot
local backpackType = backpackSlots[index].backpack
local currentItem = craftingData[index]
local validItem = currentItem.id ~= 0
