API:AddCraftingItem
From RoR Wiki
UI Lua API · Crafting functions
Version: WAR 1.4.8
Asks the server to add an item from a backpack to a crafting session (talisman making, apothecary or cultivation).
AddCraftingItem(tradeSkill, craftingSlot, backpackSlot, backpackType)
Arguments
- tradeSkill
number– AGameData.TradeSkillsvalue:CULTIVATION(3),APOTHECARY(4) orTALISMAN(5).- craftingSlot
number– For cultivation, the plot number (starting at 1). For apothecary and talisman making the client does not send it.- backpackSlot
number– Slot of the item inside the backpack, starting at 1.- backpackType
number– Which backpack the item is in, as anEA_Window_Backpack.TYPE_*value (2 = inventory, 3 = currency, 4 = crafting).
Returns
Nothing.
Details
backpackSlotandbackpackTypeare converted to an absolute inventory slot.- With trade skill 3 the request is a cultivation request for the given plot. With 4 or 5 it is a crafting "add ingredient" request for that skill. With any other value the client sends the same message type without a crafting command.
- If a certain player state flag is set, the client adds a fixed message to the
Chattext log instead of sending the request. - The client does not check that the item fits the crafting slot. The stock crafting windows check the item type themselves and track which crafting slot holds which item.
- The function needs at least four arguments and only reads the last four.
Errors
None besides the generic Invalid Parameters message when an argument is not a number.
Example
From default/ea_craftingwindow/source/apothecarywindow.lua:
if( slotNum == ApothecaryWindow.SLOT_CONTAINER)
then
AddCraftingContainer( GameData.TradeSkills.APOTHECARY, backpackSlot, backpackType )
else
AddCraftingItem( GameData.TradeSkills.APOTHECARY, slotNum, backpackSlot, backpackType )
end
Planting in a cultivation plot, from default/ea_cultivationwindow/source/cultivationwindow.lua:
AddCraftingItem( 3, plotNum, backpackSlot, backpackType )
