WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Detecting conduits (https://www.wowinterface.com/forums/showthread.php?t=58221)

doofus 09-23-20 09:52 AM

Detecting conduits
 
Hello, as per title, is there a "Conduits" interface similar perhaps to C_AzeriteEssence.GetEssences() ?

Xrystal 09-23-20 08:59 PM

I took a quick look at the API Documentation but all I can see are a bunch of items in the namespace C_Covenants but nothing referencing Conduits. That could mean there is not current API for us to use or they haven't added it to the documentation yet. With a month to go before release I would have hoped they would have had them added by now.

Hopefully someone who has got into the beta and/or is using the PTR to work on a conduit related addon has come across something can offer some suggestions.

Vrul 09-24-20 06:40 AM

This is what I found (may be typos):
C_Soulbinds.AddPendingConduit
C_Soulbinds.CanResetConduitsInSoulbind
C_Soulbinds.CommitPendingConduitsInSoulbind
C_Soulbinds.GetConduitCollection
C_Soulbinds.GetConduitCollectionData
C_Soulbinds.GetConduitCollectionDataAtCursor
C_Soulbinds.GetConduitHyperlink
C_Soulbinds.GetConduitItemLevel
C_Soulbinds.GetConduitQuality
C_Soulbinds.GetConduitSpellID
C_Soulbinds.GetPendingConduitID
C_Soulbinds.HasAnyInstalledConduitInSoulbind
C_Soulbinds.HasAnyPendingConduits
C_Soulbinds.HasPendingConduitInSoulbind
C_Soulbinds.HasPendingConduitsInSoulbind
C_Soulbinds.IsConduitInstalled
C_Soulbinds.IsConduitInstalledInSoulbind
C_Soulbinds.IsItemConduitByItemInfo
C_Soulbinds.IsUnselectedConduitPendingInSoulbind
C_Soulbinds.RemovePendingConduit
C_Soulbinds.ResetSoulbindConduits

Fizzlemizz 09-24-20 10:59 AM

In the Beta/PTR you can type "/api C_Soulbinds" in-game, click on the pink link to get a list of functions, events and tables or, extract the code and open SoulbindsDocumentation.lua under the Blizzard_APIDocumantation addon.

Xrystal 09-24-20 11:45 AM

D'oh forgot Conduits were connected to the Soulbinds and not the Covenant itself

doofus 09-27-20 03:05 PM

OK, great. Now this has brought me to another (I am sure basic) subject which I am confused about. How can an addon log/copy all the messages in a chat window? For example my addons display diagnostics like,

DEFAULT_CHAT_FRAME :AddMessage("hello",0,1,0);

How can another addon read those messages? They are not SAY, not SYSTEM, not Channel anything.

I have even tried setprinthandler(newPrintHandler) did not do anything.

Xrystal 09-27-20 03:10 PM

Quote:

Originally Posted by doofus (Post 336914)
OK, great. Now this has brought me to another (I am sure basic) subject which I am confused about. How can an addon log/copy all the messages in a chat window? For example my addons display diagnostics like,

DEFAULT_CHAT_FRAME :AddMessage("hello",0,1,0);

How can another addon read those messages? They are not SAY, not SYSTEM, not Channel anything.

I have even tried setprinthandler(newPrintHandler) did not do anything.

Have a look at something like WIM ( Wow Instant Messenger ) .. Not sure if it is up to date but I recall it keep ing a record of the chat windows. The DEFAULT_CHAT_FRAME I believe is the equivalent of ChatFrame1. I suspect what they do is make a copy of the message being received by the chat window and store it in a local table and then save that table out .. then when you log back in do the reverse to get it back into the window as if it was a new message.

doofus 09-28-20 10:29 AM

I had a look, cannot run because my son is using my WoW account, anyway, it seems it uses
ChatFrame_AddMessageEventFilter
and
RegisterEvent

Firstly, there is no event being fired when system or other messages appear in the chat frame. Also there is no way to add a filter because these messages are not channel messages.

That is how I understand it and I doubt that WIM "sees" or copies those messages. Remember they are not "SAY" or "YELL" or channel, eg "TRADE" or "PARTY" - they are "System" messages or even, unclassified? I am not sure.

I will wait for my son to stop playing and will have a look again at WIM.

Xrystal 09-28-20 11:56 AM

You might be right there. It was just a thought. It still may help you see how it may work for you. A little trial and error when your son isn't playing :P

Vrul 09-28-20 05:06 PM

You could just hook the AddMessage method:
Code:

hooksecurefunc(DEFAULT_CHAT_FRAME, "AddMessage",  function(self, message, ...)
        -- Do something with message
end)

Just remember if you want to output something to DEFAULT_CHAT_FRAME from within the hook you'll need to setup a flag to ignore that message or an endless loop will occur.

doofus 09-29-20 06:51 AM

OK, I have managed to hook onto the chat functions!

Regarding covenants and conduits, I think the below extracts your active conduits. I have just tested it with all combinations I could think of, eg some conduits taken, some not, changing paths etc. It returns a table with spell ID and spell name for each node and conduit in your chosen soulbind's path.

Code:

-- *********************************************************************
-- patch 9.x.x Shadowlands SL
local function DetermineActiveCovenantAndSoulbindAndConduits()
  local covenantID = C_Covenants.GetActiveCovenantID();
  if ( not covenantID or covenantID == 0 ) then
    BA_Data["function LogTextLine"](string.format("No active covenants"));
    return nil;
  end
  local covenantData = C_Covenants.GetCovenantData(covenantID);
  if ( not covenantData ) then
    BA_Data["function LogTextLine"](string.format("No covenant found"));
    return nil;
  end
  local covenantName = covenantData.name;
  BA_Data["function LogTextLine"](string.format("Covenant:[%s]",covenantName));
  local soulbindID = C_Soulbinds.GetActiveSoulbindID();
  if ( not soulbindID or soulbindID == 0 ) then
    BA_Data["function LogTextLine"](string.format("No active soulbinds"));
    return nil;
  end
  local soulbindData = C_Soulbinds.GetSoulbindData(soulbindID);
  if ( not soulbindData ) then
    BA_Data["function LogTextLine"](string.format("No active soulbinds"));
    return nil;
  end
  local id = soulbindData["ID"];
  --local covenantID = soulbindData["covenantID"];
  local soulbindName = soulbindData["name"];
  local description = soulbindData["description"];
  local tree = soulbindData["tree"];
  local nodes = tree["nodes"];
  --BA_Data["function LogTextLine"](string.format("covenant:[%s] - soulbind ID:[%d] - id:[%d] - covenantID:[%d] - name:[%s]",covenantName,soulbindID,id,covenantID,name));
  --BA_Data["function LogTextLine"](string.format("nodes:-"));
  local activeConduitsSpells = {};
  activeConduitsSpells.covenantName = covenantName;
  activeConduitsSpells.soulbindName = soulbindName;
  activeConduitsSpells.conduits = {};
  for _, ve in pairs(nodes) do
    local node_id = ve["ID"];
    local node_row = ve.row;
    local node_column = ve.column;
    local node_spellID = ve.spellID; -- this will be 0 for uninit spell, not nil
    local node_conduitID = ve.conduitID; -- this will be 0 for uninit conduit, not nil
    local node_conduitRank = ve.conduitRank;
    local node_state = ve.state;
    local node_conduitType = ve.conduitType; -- this can be nil
    if ( node_state == 3 ) then
      --[====[
      BA_Data["function LogTextLine"](string.format("nodeid:[%s] - row:[%s] - col:[%s] - spellID:[%s] - conduitID:[%s] - conduitRank:[%s] - state:[%s][%s] - conduitType:[%s][%s]",
          tostring(node_id),
          tostring(node_row),
          tostring(node_column),
          tostring(node_spellID),
          tostring(node_conduitID),
          tostring(node_conduitRank),
          tostring(node_state),
          tostring(( node_state == 1 and "blank" or node_state == 3 and "used" or "unknown" )),
          tostring(node_conduitType),
          tostring(( node_conduitType == 1 and "Potency" or node_conduitType == 2 and "Endurance" or node_conduitType == 0 and "Finesse" or "Unknown"  ))
        ));
      --]====]
     
      local node_spellName;
      if ( node_spellID ~= 0 ) then
        node_spellName = GetSpellInfo(node_spellID);
      elseif ( node_conduitID ~= 0 ) then
        local conduitSpellID = C_Soulbinds.GetConduitSpellID(node_conduitID,node_conduitRank);
        node_spellID = conduitSpellID;
        node_spellName = GetSpellInfo(conduitSpellID);
      else
        node_spellID = nil;
        node_spellName = nil;
      end
      if ( node_spellID ) then
        activeConduitsSpells.conduits[#activeConduitsSpells.conduits + 1] = { spellID = node_spellID, spellName = node_spellName };
      end
    end
  end
  BA_Data["function LogTextLine"](string.format("covenant:[%s] - soulbindName:[%s]",activeConduitsSpells.covenantName,activeConduitsSpells.soulbindName));
  for _, ve in pairs(activeConduitsSpells.conduits) do
    BA_Data["function LogTextLine"](string.format("spellID:[%d] - spellName:[%s]",ve.spellID,tostring(ve.spellName)));
  end
 
  --BA_Data["function LogTextLine"](string.format("-- end nodes"));
  return activeConduitsSpells;
end







and also

  -- patch 9.x.x Shadowlands SL
  -- listen to soulbinds/conduits changes
  self:RegisterEvent("COVENANT_CALLINGS_UPDATED");
  self:RegisterEvent("COVENANT_CHOSEN");
  self:RegisterEvent("SOULBIND_ACTIVATED");
  self:RegisterEvent("SOULBIND_PATH_CHANGED");
  self:RegisterEvent("SOULBIND_CONDUITS_RESET");
  self:RegisterEvent("SOULBIND_NODE_UPDATED");
  self:RegisterEvent("GARRISON_UPDATE");



All times are GMT -6. The time now is 04:46 AM.

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