Quantcast
WoWInterface - View Single Post - Need help understanding why loop is not always processing entire table
View Single Post
08-30-21, 10:59 AM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,450
You've set up your data tables (sectionNames and mountList) as globals. They should really be included in your namespace table (core.sectionNames and core.mountList).

You could add the collection loaded check to MCL_Load:CreateMenu() before creating the frame and get rid of the whole init frame ADDON_LOADED stuff and just use the slash command
Lua Code:
  1. local _, core = ...; -- Namespace
  2. -------------------------------------------------------------
  3.  
  4. function core:Print(...)
  5.     local hex = select(4, self.Config:GetThemeColor());
  6.     local prefix = string.format("|cff%s%s|r", hex:upper(), "MCL:");   
  7.     DEFAULT_CHAT_FRAME:AddMessage(string.join(" ", prefix, ...));
  8. end
  9.  
  10. SLASH_MCL1 = "/mcl";
  11. SlashCmdList.MCL = core.Config.Toggle;

Lua Code:
  1. function MCL_Load:CreateMenu()
  2.     core:Print("Welcome back", UnitName("player").."!");
  3.     --Master Frame for addon
  4.     if not IsAddOnLoaded("Blizzard_Collections") then
  5.         LoadAddOn("Blizzard_Collections")
  6.     end
  7.  
  8.     local MCL = CreateFrame("Frame", "MLCFrame", UIParent, "BasicFrameTemplateWithInset");
  9.     ...
  10. end

The "Welcome back" message is not really needed, they know they are playing and using your addon if they've gotten this far so...

You're also using a lot of globals with names like totalCollected and u and total and x and y ... While it's easy for accessing data in various parts of your code, you really need to make sure that global names are absolutely unique to your addon MCL_totalCollected, MCL_u, MCL_total etc. It may not be the cause of you problems but it will help stopping future possible problems.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-30-21 at 01:23 PM.
  Reply With Quote