Thread Tools Display Modes
05-05-19, 03:45 AM   #1
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
C_MythicPlus.GetOwnedKeystoneChallengeMapID() and other strange things :)

Hi all,

I am doing a little ldb for m+ keystone tracker using standard databroker and LibQTip.



One of the problem I am facing is that the:

Lua Code:
  1. C_MythicPlus.GetOwnedKeystoneChallengeMapID()

seems not available at the PLAYER_ENTERING_WORLD event.

But I am unable to find what I have to load or wait to have this value.
Infact after a while I got it. Mah.

Another problem really strange is that a character usually get the data of the previous one logged before in the:
Lua Code:
  1. C_MythicPlus.GetWeeklyBestForMap(mapID)

I check similar addons and all seems to have this kind of problem, is it a known bug ?
I.e IKeyStones use this code to bypass:

Lua Code:
  1. function iKS:scanCharacterMaps()
  2.     if not iKS:createPlayer() then return end
  3.     local maps = C_ChallengeMode.GetMapTable()
  4.     local maxCompleted = 0
  5.     for _, mapID in pairs(maps) do
  6.         local _, level, _, affixes, members = C_MythicPlus.GetWeeklyBestForMap(mapID)
  7.         if members then
  8.             for _,member in pairs(members) do -- Avoid leaking from another char (wtf??, how is this even possible)
  9.                 if member.name == unitName then
  10.                     if level and level > maxCompleted then
  11.                         maxCompleted = level
  12.                     end
  13.                     break;
  14.                 end
  15.             end
  16.         end
  17.     end
  18.     if iKeystonesDB[player].maxCompleted and iKeystonesDB[player].maxCompleted < maxCompleted then
  19.         iKeystonesDB[player].maxCompleted = maxCompleted
  20.     end
  21. end

Thanks so much for any tips.


P.s.
Also this seems to me strange and odd:

__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.

Last edited by gmarco : 05-05-19 at 03:48 AM.
  Reply With Quote
05-08-19, 05:54 AM   #2
Voopie
A Murloc Raider
 
Voopie's Avatar
Join Date: Sep 2018
Posts: 4
Have you tried this event - MYTHIC_PLUS_CURRENT_AFFIX_UPDATE?
It helped me but the task was a bit different

Or C_Timer.After(2, ...) at PLAYER_LOGIN/PLAYER_ENTERING_WORLD may help

Last edited by Voopie : 05-08-19 at 05:57 AM.
  Reply With Quote
05-09-19, 11:50 PM   #3
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Hi,
thanks for the reply.

The only way I succeded in let things works is with code like this:

Lua Code:
  1. local function UpdatePg()
  2.  
  3.     if UnitLevel("player") == GetMaxPlayerLevel() then             
  4.    
  5.         -- Refresh the current player in the array
  6.         GMKEYSTONE_NAMES[realmName.."-"..playerName] = {}
  7.         GMKEYSTONE_NAMES[realmName.."-"..playerName]["NAME"] = realmName.."-"..playerName
  8.         GMKEYSTONE_NAMES[realmName.."-"..playerName]["CLASS"] = select(2,UnitClass("player"))
  9.         GMKEYSTONE_NAMES[realmName.."-"..playerName]["WEEKLYKEY"] = "-"
  10.         GMKEYSTONE_NAMES[realmName.."-"..playerName]["MYKEY"] = "-"
  11.        
  12.         if C_MythicPlus.GetOwnedKeystoneChallengeMapID() then
  13.             -- you have a keystone
  14.             GMKEYSTONE_NAMES[realmName.."-"..playerName]["MYKEY"] = C_ChallengeMode.GetMapUIInfo(C_MythicPlus.GetOwnedKeystoneChallengeMapID()) .. " (" .. C_MythicPlus.GetOwnedKeystoneLevel() ..")"
  15.             dataobj.text = short[C_MythicPlus.GetOwnedKeystoneChallengeMapID()] .. ":" .. C_MythicPlus.GetOwnedKeystoneLevel()
  16.            
  17.             -- you have done a dungeon+
  18.             if C_MythicPlus.GetWeeklyChestRewardLevel() ~= 0 then
  19.                 GMKEYSTONE_NAMES[realmName.."-"..playerName]["WEEKLYKEY"], _ = C_MythicPlus.GetWeeklyChestRewardLevel()
  20.             end
  21.  
  22.         else -- you don't have a keystone
  23.  
  24.             -- but you have a reward ready
  25.             if C_MythicPlus.IsWeeklyRewardAvailable() then
  26.                 GMKEYSTONE_NAMES[realmName.."-"..playerName]["WEEKLYKEY"] = "*"
  27.                 dataobj.text = "chest ready"           
  28.  
  29.             end
  30.             -- if you don't have a reward ready is already defined = "-" as default
  31.            
  32.         end
  33.        
  34.     end
  35. end
  36.  
  37.  
  38. -- code
  39.  
  40. local frame = CreateFrame("Frame")
  41. frame:RegisterEvent("PLAYER_ENTERING_WORLD")
  42. frame:SetScript("OnEvent", function(self, event, arg1)
  43.     UpdatePg()
  44. end)

Probably there will be a more correct way of doing thing but I was not able to find it
I use the idea that if I have a keystone in the bag I did at least a m+ dungeon. I hope that it is right


Thanks.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.

Last edited by gmarco : 05-10-19 at 12:08 AM.
  Reply With Quote
05-10-19, 12:12 AM   #4
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Hi,
because it is always better to check the entire code and because it is a small addon I paste it here.

Lua Code:
  1. local ADDON = ...
  2. local playerName = UnitName("player")
  3. local realmName = GetRealmName()
  4.  
  5. local string_format = string.format
  6. GMKEYSTONE_NAMES = GMKEYSTONE_NAMES or {}
  7.  
  8. local short = {
  9.   [244] = "AD",
  10.   [245] = "Free",
  11.   [246] = "TD",
  12.   [247] = "MOTHER",
  13.   [248] = "WM",
  14.   [249] = "KR",
  15.   [250] = "ToS",
  16.   [251] = "Under",
  17.   [252] = "SotS",
  18.   [353] = "SoB",
  19. }
  20.  
  21.  -- Get a reference to the lib
  22.  local LibQTip = LibStub('LibQTip-1.0')
  23.  local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
  24. local dataobj = ldb:NewDataObject(ADDON, {
  25.     type = "data source",
  26.     icon = "Interface\\Addons\\"..ADDON.."\\icon.tga",
  27.     text = "none",
  28. })
  29.  
  30. local function UpdatePg()
  31.  
  32.     if UnitLevel("player") == GetMaxPlayerLevel() then             
  33.    
  34.         -- Refresh the current player in the array
  35.         GMKEYSTONE_NAMES[realmName.."-"..playerName] = {}
  36.         GMKEYSTONE_NAMES[realmName.."-"..playerName]["NAME"] = realmName.."-"..playerName
  37.         GMKEYSTONE_NAMES[realmName.."-"..playerName]["CLASS"] = select(2,UnitClass("player"))
  38.         GMKEYSTONE_NAMES[realmName.."-"..playerName]["WEEKLYKEY"] = "-"
  39.         GMKEYSTONE_NAMES[realmName.."-"..playerName]["MYKEY"] = "-"
  40.        
  41.         if C_MythicPlus.GetOwnedKeystoneChallengeMapID() then
  42.             -- you have a keystone
  43.             GMKEYSTONE_NAMES[realmName.."-"..playerName]["MYKEY"] = C_ChallengeMode.GetMapUIInfo(C_MythicPlus.GetOwnedKeystoneChallengeMapID()) .. " (" .. C_MythicPlus.GetOwnedKeystoneLevel() ..")"
  44.             dataobj.text = short[C_MythicPlus.GetOwnedKeystoneChallengeMapID()] .. ":" .. C_MythicPlus.GetOwnedKeystoneLevel()
  45.            
  46.             -- you have done a dungeon+
  47.             if C_MythicPlus.GetWeeklyChestRewardLevel() ~= 0 then
  48.                 GMKEYSTONE_NAMES[realmName.."-"..playerName]["WEEKLYKEY"], _ = C_MythicPlus.GetWeeklyChestRewardLevel()
  49.             end
  50.  
  51.         else -- you don't have a keystone
  52.  
  53.             -- but you have a reward ready
  54.             if C_MythicPlus.IsWeeklyRewardAvailable() then
  55.                 GMKEYSTONE_NAMES[realmName.."-"..playerName]["WEEKLYKEY"] = "*"
  56.                 dataobj.text = "chest ready"           
  57.             end
  58.             -- if you don't have a reward ready, MYKEY is already defined = "-" as default
  59.         end
  60.     end
  61. end
  62.  
  63.  
  64. local function anchor_OnEnter(self)
  65.  
  66.     -- build pg data
  67.     UpdatePg()
  68.    
  69.     -- Acquire a tooltip with 3 columns, respectively aligned to left, center and right
  70.     local tooltip = LibQTip:Acquire(ADDON, 3, "LEFT", "CENTER", "CENTER")
  71.     self.tooltip = tooltip
  72.  
  73.     -- Clear
  74.     tooltip:Clear()
  75.    
  76.     -- Use this instead of dataobj.OnLeave(frame) if you want to delay.
  77.     --
  78.     -- tooltip:SetAutoHideDelay(0.25, self)
  79.     -- function tooltip.OnRelease()
  80.     --  self.tooltip = nil
  81.     -- end
  82.  
  83.     local line, column = tooltip:AddHeader()
  84.     tooltip:SetCell(line, 1, "gmKeyStone")
  85.  
  86.     -- Add an empty line, using all columns
  87.     tooltip:AddLine()
  88.  
  89.  
  90.     local line, column = tooltip:AddLine('','Mythic key','Reward Lvl')
  91.     tooltip:SetLineTextColor(line,0,1,0)
  92.    
  93.     tooltip:AddSeparator()
  94.    
  95.     -- Show all Keys
  96.     for name in pairs(GMKEYSTONE_NAMES) do 
  97.         line, column = tooltip:AddLine()
  98.         tooltip:SetCell(line, 1, GMKEYSTONE_NAMES[name]["NAME"])
  99.         tooltip:SetCell(line, 2, GMKEYSTONE_NAMES[name]["MYKEY"])
  100.         tooltip:SetCell(line, 3, GMKEYSTONE_NAMES[name]["WEEKLYKEY"])      
  101.         local r = _G["RAID_CLASS_COLORS"][GMKEYSTONE_NAMES[name]["CLASS"]].r
  102.         local g = _G["RAID_CLASS_COLORS"][GMKEYSTONE_NAMES[name]["CLASS"]].g
  103.         local b = _G["RAID_CLASS_COLORS"][GMKEYSTONE_NAMES[name]["CLASS"]].b
  104.         tooltip:SetCellTextColor(line, 1, r, g, b)
  105.     end
  106.     tooltip:AddSeparator()
  107.     local line, column = tooltip:AddLine('','','')
  108.     local line, column = tooltip:AddLine('','','')
  109.     local line, column = tooltip:AddLine('Left Btn','','Open Group Finder')
  110.     tooltip:SetLineTextColor(line,0,1,0)
  111.     local line, column = tooltip:AddLine('Shift + Left Btn','','Reset PG')
  112.     tooltip:SetLineTextColor(line,0,1,0)
  113.     local line, column = tooltip:AddLine('Shift + Right Btn','','Reset data')
  114.     tooltip:SetLineTextColor(line,0,1,0)
  115.  
  116.     -- Use smart anchoring code to anchor the tooltip to our frame
  117.     tooltip:SmartAnchorTo(self)
  118.  
  119.     -- Show it, et voilą !
  120.     tooltip:Show()
  121.    
  122. end
  123.  
  124. local function anchor_OnLeave(self)
  125.    -- Release the tooltip
  126.    LibQTip:Release(self.tooltip)
  127.    self.tooltip = nil
  128. end
  129.  
  130. function dataobj.OnClick(frame, button)  
  131.    
  132.     if button == "RightButton" and IsShiftKeyDown() then
  133.         GMKEYSTONE_NAMES = {}
  134.         ReloadUI()
  135.     end
  136.     if button == "LeftButton" and IsShiftKeyDown() then
  137.         GMKEYSTONE_NAMES[realmName.."-"..playerName] = {}
  138.         ReloadUI()
  139.     end
  140.    
  141.     if button == "LeftButton" then
  142.         PVEFrame_ToggleFrame()
  143.     end
  144.    
  145. end
  146.  
  147. function dataobj.OnEnter(frame)
  148.     anchor_OnEnter(frame)
  149. end
  150.  
  151. function dataobj.OnLeave(frame)
  152.     anchor_OnLeave(frame)
  153. end
  154.  
  155. local frame = CreateFrame("Frame")
  156. frame:RegisterEvent("PLAYER_ENTERING_WORLD")
  157. frame:SetScript("OnEvent", function(self, event, arg1)
  158.     UpdatePg()
  159. end)

Thanks all.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » C_MythicPlus.GetOwnedKeystoneChallengeMapID() and other strange things :)

Thread Tools
Display Modes

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