ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   How can I get the research slots in use? (https://www.esoui.com/forums/showthread.php?t=974)

Artajörn 04/17/14 09:44 AM

How can I get the research slots in use?
 
Hi,

I'm trying to get the number of free research slots. To do that, I'm using the following code:

Code:

local currentSimultaneousResearches = 0
local researchLines = {}
       
for index = 1, GetNumSmithingResearchLines(CRAFTING_TYPE_BLACKSMITHING), 1 do
        researchLines[index] = GetSmithingResearchLineInfo(CRAFTING_TYPE_BLACKSMITHING, index)
               
        if researchLines[index].timeRequiredForNextResearchSecs > 0 then
                currentSimultaneousResearches = currentSimultaneousResearches + 1
        end
end

It seems not work, so I must be doing something wrong. Can you help me, please?

Regards and thanks in advance. :)

Stormknight 04/17/14 10:21 AM

Here's a working function from my AwesomeInfo addon that should help you.

Code:

numberOfEmptySlots, RemainingTime = AI.GetResearchTimer(CRAFTING_TYPE_BLACKSMITHING)

function AI.GetResearchTimer(craftType)
    local maxTimer = 2000000
    local maxResearch = GetMaxSimultaneousSmithingResearch(craftType)  -- This is the number of research slots for this profession
    local maxLines = GetNumSmithingResearchLines(craftType)    -- This is the number of different items craftable by this profession
    for i = 1, maxLines, 1 do      -- loop through the different craftable items, looking to see if there is research on that item
        name, icon, numTraits, timeRequiredForNextResearchSecs = GetSmithingResearchLineInfo(craftType, i)  -- Get info on that specific item
        for j = 1, numTraits, 1 do      -- loop through the traits, looking for one that is being researched
            duration, timeRemaining = GetSmithingResearchLineTraitTimes(craftType, i, j)
            if (duration ~= nil and timeRemaining ~= nil) then
                maxResearch = maxResearch - 1
                maxTimer = math.min(maxTimer,timeRemaining)
            end
        end
    end
    if (maxResearch > 0) then  -- There is an unused research slot.
        maxTimer = 0
    end
    return maxResearch, maxTimer
end -- AI.GetResearchTimer


Vuelhering 04/17/14 12:30 PM

Yeah, you want the GetSmithingResearchLineTraitTimes() which returns non nil when it's being researched.

Artajörn 04/25/14 11:42 AM

Thank you very much for the answer. It helped me alot. ;)


All times are GMT -6. The time now is 03:06 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI