Thread Tools Display Modes
04/17/14, 09:44 AM   #1
Artajörn
Join Date: Apr 2014
Posts: 19
Question 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.
  Reply With Quote
04/17/14, 10:21 AM   #2
Stormknight
 
Stormknight's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 128
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
  Reply With Quote
04/17/14, 12:30 PM   #3
Vuelhering
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 169
Yeah, you want the GetSmithingResearchLineTraitTimes() which returns non nil when it's being researched.

Last edited by Vuelhering : 04/17/14 at 12:47 PM.
  Reply With Quote
04/25/14, 11:42 AM   #4
Artajörn
Join Date: Apr 2014
Posts: 19
Thank you very much for the answer. It helped me alot.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » How can I get the research slots in use?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off