Thread Tools Display Modes
08/01/15, 07:33 PM   #1
Weolo
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 79
Event_smithing_trait_research_completed

This event is not always firing when crafting research finishes.
Sometimes it does, sometimes it doesn't.
I am trying to monitor it to get more information.

I log on to a character that I know has finished researching a trait, and sometimes the event fires but not everytime. I am always seeing xp gain show from the lootdrop addon, it seems when the event is not firing then no text appears in to the top right of the screen telling you which item was researched.

This is the code I have right now.
Is this the best way to use the event?
Has anyone else had a problem like this?

Lua Code:
  1. local ADDON_NAME = "something"
  2. local player_activated = false
  3.  
  4. local function OnResearchCompleted(eventCode, craftingSkillType, researchLineIndex, traitIndex)
  5.     LogMe:add("Function OnResearchCompleted("..tostring(eventCode)..", "..craftingSkillType..", "..researchLineIndex..", "..traitIndex..")")
  6. end
  7.  
  8. local function OnPlayerActivated()
  9.     if player_activated then return end --Only the first time
  10.     player_activated = true
  11.     EVENT_MANAGER:UnregisterForEvent(ADDON_NAME, EVENT_PLAYER_ACTIVATED)
  12.     LogMe:add("Event OnPlayerActivated")
  13. end
  14.  
  15. local function OnLoaded(eventType, addonName)
  16.     if addonName ~= ADDON_NAME then return end
  17.     EVENT_MANAGER:UnregisterForEvent(ADDON_NAME, EVENT_ADD_ON_LOADED)
  18.     LogMe:add("Event OnLoaded")
  19.  
  20.     EVENT_MANAGER:RegisterForEvent(ADDON_NAME, EVENT_SMITHING_TRAIT_RESEARCH_COMPLETED, OnResearchCompleted)
  21.     EVENT_MANAGER:RegisterForEvent(ADDON_NAME, EVENT_PLAYER_ACTIVATED, OnPlayerActivated)
  22. end
  23.  
  24. EVENT_MANAGER:RegisterForEvent(ADDON_NAME, EVENT_ADD_ON_LOADED, OnLoaded)
  Reply With Quote
08/01/15, 08:23 PM   #2
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Weolo View Post
This event is not always firing when crafting research finishes.
Sometimes it does, sometimes it doesn't.
I am trying to monitor it to get more information.

I log on to a character that I know has finished researching a trait, and sometimes the event fires but not everytime.
Has anyone else had a problem like this?
I don't think it fires when you log in if the trait finished while you were offline.
You could use EVENT_SMITHING_TRAIT_RESEARCH_STARTED, to mark traits as known. To start research the game/character has to be active so the addon is running so your guaranteed not to miss it and since you can't cancel research or research it again, the trait is as good as known.

If you didn't want to mark them early like that I think you have to just check all of the unknown traits on login to see if anything new was learned while offline.

Last edited by circonian : 08/01/15 at 08:27 PM.
  Reply With Quote
08/01/15, 09:17 PM   #3
Weolo
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 79
Originally Posted by circonian View Post
I don't think it fires when you log in if the trait finished while you were offline.
Okay I can work with that.

Originally Posted by circonian View Post
You could use EVENT_SMITHING_TRAIT_RESEARCH_STARTED, to mark traits as known.
I am already using this event but to mark traits as being researched.

Originally Posted by circonian View Post
I think you have to just check all of the unknown traits on login
I am doing this already

Keeping all your advice in mind I think I will re-write the way I am capturing the trait information just to rule out any potential problems.

Thanks for the help.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Event_smithing_trait_research_completed


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