Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement

Request the loading of an On-Demand AddOn.

loaded, reason = LoadAddOn(index or "name")

Parameters

Arguments

(index or "name")
index
Integer - The index of the AddOn in the user's AddOn list. Note that you cannot access Blizzard-provided AddOns through this mechanism.
name
String - The name of the AddOn to be queried. You can access Blizzard-provided AddOns through this mechanism.

Returns

loaded, reason
loaded
Flag - Indicates if the AddOn was loaded, true if it is, false if it is not.
reason
String - The non-localized reason why the AddOn cannot load, or nil if the addon loaded.

Usage

_G["ADDON_" .. reason] localizes the reason to the client language. A default, localized error message may be constructed using format() with ADDON_LOAD_FAILED, the AddOn name, and _G["ADDON_" .. reason]

local loaded, reason = LoadAddOn("MyOtherAddOn")

if not loaded then
  print(format(ADDON_LOAD_FAILED, "MyOtherAddOn", _G["ADDON_"..reason]));
  if reason == "DISABLED" then
    -- do stuff 
  elseif reason == "MISSING" then
    -- do other stuff
  elseif reason == "CORRUPT" then
    -- do something else
  elseif reason == "INTERFACE_VERSION" then
    -- do something different
  end
end

Details

Prior to the 1.8 patch, this could be used to load addons which were not on-demand if they were disabled at start up and then enabled during the play session. The 1.8 patch restricted this to ONLY addons which are truly marked on demand in their .toc files (## LoadOnDemand: 1).

Reason Codes

(taken from FrameXML\GlobalStrings.lua)
(they are all prefixed with "ADDON_", use _G["ADDON_"..reason] for localizing)

BANNED
"Banned"; -- Addon is banned by the client.
CORRUPT
"Corrupt"; -- The addon's file(s) are corrupt.
DEP_BANNED
"Dependency banned"; -- Addon's dependency is banned by the client.
DEP_CORRUPT
"Dependency corrupt"; -- The addon's dependency cannot load because its file(s) are corrupt.
DEP_DISABLED
"Dependency disabled"; -- The addon cannot load without its dependency enabled.
DEP_INCOMPATIBLE
"Dependency incompatible"; -- The addon cannot load if its dependency cannot load.
DEP_MISSING
"Dependency missing"; -- The addon's dependency is physically not there.
DEP_NOT_DEMAND_LOADED
"Dependency not loadable on demand"; -- The addon's dependency must be loadable on demand too.
DISABLED
"Disabled"; -- Addon is disabled on the character select screen.
INCOMPATIBLE
"Incompatible"; -- The addon is too old.
MISSING
"Missing"; -- The addon is physically not there.
NOT_DEMAND_LOADED
"Not loadable on demand"; -- As of 1.8 only addons marked as LoadOnDemand can be loaded via this function.
INTERFACE_VERSION
-- Unknown, presumably the interface version in the .toc file is incorrect

See Also

Advertisement