Quantcast ESOUI - View Single Post - While loop breaking ESO
View Single Post
10/27/19, 05:32 AM   #7
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 2,622
Refine complete = Use event_craft_started -> check if in refine mode (API functiosn exists somewhere in esoui/ingame/crafting) -> event_craft_complete it's done or event_craft_failed / event_craft_aborted it was not finished correctly

Works for all other craftings as well.

Helpfull functions in here:
https://github.com/esoui/esoui/blob/...ftingutils.lua

There exists the function ZO_SmithingExtractionSlot:IsInRefineMode()
ZO_SmithingExtractionSlot should relate to the global variable SMITHING.refinementPanel

I'm using it like this within DoItAll:
Lua Code:
  1. function DoItAll.IsShowingExtraction()
  2.     return not ZO_EnchantingTopLevelExtractionSlotContainer:IsHidden()
  3. end
  4.  
  5. function DoItAll.IsShowingDeconstruction()
  6.     return not ZO_SmithingTopLevelDeconstructionPanelSlotContainer:IsHidden()
  7. end
  8.  
  9. function DoItAll.IsShowingRefinement()
  10.     return not ZO_SmithingTopLevelRefinementPanelSlotContainer:IsHidden()
  11. end
  12.  
  13. local function GetExtractionContainerFunctionCtrlAndPanel()
  14.   if DoItAll.IsShowingExtraction() then
  15.     return ZO_EnchantingTopLevelInventoryBackpack, ExtractEnchantingItem, ENCHANTING, ENCHANTING
  16.   elseif DoItAll.IsShowingDeconstruction() then
  17.     return ZO_SmithingTopLevelDeconstructionPanelInventoryBackpack, ExtractOrRefineSmithingItem, SMITHING, SMITHING.deconstructionPanel
  18.   elseif DoItAll.IsShowingRefinement() then
  19.     return ZO_SmithingTopLevelRefinementPanelInventoryBackpack, ExtractOrRefineSmithingItem, SMITHING, SMITHING.refinementPanel
  20.   end
  21. end

And for the extraction then:
Lua Code:
  1. container, extractFunction, craftingTableCtrlVar, craftingTablePanel = GetExtractionContainerFunctionCtrlAndPanel()

Lua Code:
  1. if craftingTableCtrlVar.CanItemBeAddedToCraft then
  2.             extractable = craftingTableCtrlVar:CanItemBeAddedToCraft(slot.bagId, slot.slotIndex)
  3.             --Refinemant only if stackcount >= 10
  4.             if DoItAll.IsShowingRefinement() and doitall_slot.stackCount ~= nil and doitall_slot.stackCount < 10 then
  5.                 extractable = false
  6.             end
  7.             --Some more checks like the maximum multicraft items (ZOs added a maximum constant MAX_ITERATIONS_PER_DECONSTRUCTION here -> See file DoItAll/src/ExtractAll/Extraction.lua)
  8.            --Check if the items to add to the extract slot are >= MAX_ITERATIONS_PER_DECONSTRUCTION (for refine it needs to be multiplied by the stackCount as each item of the 10 to refine counts as a single one!!!) and if it's => above the constant MAX_ITERATIONS_PER_DECONSTRUCTION extract those first (there cannot be added more then!) and return with the next "batch" of items to extract.
  9.             ...
  10.             if extracable then
  11.               craftingTableCtrlVar:AddItemToCraft(slot.bagId, slot.slotIndex))
  12.            endif

And at the end check if only 1 or multiple items are added to the slot and extract them:
Lua Code:
  1. if extractionSlot:HasOneItem() and craftingTablePanel.ExtractSingle then
  2.    craftingTablePanel:ExtractSingle()
  3. elseif extractionSlot:HasMultipleItems() then
  4.  if showConfirmatioNDialog then
  5.     craftingTablePanel:ConfirmExtractAll()
  6.  else
  7.  --Attention: Direct extraction, no confirmation dialog!
  8.    craftingTablePanel:ExtractAll()
  9. end
  10.  
  11. end


I'm registering a callback function at EVENT_CRAFT_STARTED for EVENT_CRAFT_COMPLETE and EVENT_CRAFT_FALIED. If one of them gets called it will be unregistering the 2 callback functions again. Same if next EVENT_CRAFT_STARTED is called.

Hope this helps.

Last edited by Baertram : 10/27/19 at 05:50 AM.
  Reply With Quote