MCom.varsLoaded
From WoWWiki
This article is a part of the documentation of the MCom function library
While this function is still in place and usable, the need for using it is no longer there. Blizzard has made the client so that the variables this checks for are always available now, and the reason for using this function, and the methodology it is made for, is now deperecated. It is now safe to use LoadConfig and SaveConfig on variables loaded.
--[[
varsLoaded
This will simply check to see if the variables needed to be able to use MCom.loadConfig have been loaded.
To use this properly you must have an OnEvent function. You must have registered for the "UNIT_NAME_UPDATE"
event. In your OnEvent handler you need to check if that event has occured, and if it has if the arg1 is player.
You should also have a variable that keeps up with whether or not you have loaded your config, and only try to
do so if it hasn't loaded.
Ex (somewhere in the OnLoad handler) this will either register with the UI to call ModName.LoadConfig when
they load their configuration, or it will register a "UNIT_NAME_UPDATE" event for you:
MCom.registerForLoad(ModName.LoadConfig);
Ex (somewhere in the OnEvent handler) this will handle waiting till the right vars are loaded before calling
the config, when there is no UI around:
if (( event == "UNIT_NAME_UPDATE" ) and (arg1 == "player") and (not ModName.VarsLoaded)) then
if ( MCom.varsLoaded() ) then
ModName.VarsLoaded = true;
ModName.LoadConfig();
end
end
NOTE: Make sure you're LoadConfig function only loads the config once, as some UIs might call the function more
than once.
Returns:
true - the variables needed to load the config are present and proper
false - the variables needed to load the config are not present or not proper
]]--
