WoW:API LoadAddOn: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
m (Move page script moved page API LoadAddOn to API LoadAddOn without leaving a redirect)
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<center>'''LoadAddOn'''</center>
{{wowapi}}
 
Request the loading of an On-Demand AddOn.
Request the loading of an On-Demand AddOn.
loaded, reason = LoadAddOn(index or "name")


loaded, reason = LoadAddOn(index or "name")
== Parameters ==
== Parameters ==
=== Arguments ===
=== Arguments ===
Line 9: Line 8:


:;index : Integer - The index of the AddOn in the user's AddOn list. Note that you cannot access Blizzard-provided AddOns through this mechanism.
:;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 queries. You can 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 ===
=== Returns ===
:loaded, reason
:loaded, reason


:;loaded : Flag - Indicates if the AddOn was loaded, 1 if it is, nil if it is not.
:;loaded : Flag - Indicates if the AddOn was loaded, 1 if it is, nil if it is not.
:;reason : String - The reason why the AddOn cannot be loaded. This is nil if the addon was loaded, otherwise it contains a code indicating the reason. (Observed reason codes: "DISABLED", "NOT_DEMAND_LOADED", "MISSING", "CORRUPT", "INTERFACE_VERSION", "DEP_MISSING", "DEP_INTERFACE_VERSION" and I asume other DEP_ reasons)
:;reason : String - The reason why the AddOn cannot be loaded. This is nil if the addon was loaded, otherwise it contains a code indicating the reason.


=== Usage ===
=== Usage ===
  local loaded,reason = LoadAddOn("MyOtherAddOn")
  local loaded, reason = LoadAddOn("MyOtherAddOn")
  if (not loaded) then
   if (reason == "DISABLED") then
if not loaded then
    do stuff
   if reason == "DISABLED" then
   elseif (reason == "MISSING") then
    -- do stuff
    do other stuff
   elseif reason == "MISSING" then
   elseif (reason == "CORRUPT") then
    -- do other stuff
    do something else
   elseif reason == "CORRUPT" then
   elseif (reason == "INTERFACE_VERSION") then
    -- do something else
    do something different
   elseif reason == "INTERFACE_VERSION" then
    -- do something different
   end
   end
  else
else
   do something special
   -- do something special
  end
end


== Details ==
== 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 will restrict this to ONLY addons which are truly marked on demand in their .toc files (## LoadOnDemand: 1).
: 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===
__NOTOC__
(taken from FrameXML\GlobalStrings.lua)<br />
{{Template:WoW API}}
(they are all prefixed with "ADDON_", use getglobal("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.
:;INTERACE_VERSION : -- Unknown, presumably the interface version in the .toc file is incorrect

Latest revision as of 04:46, 15 August 2023

WoW API < LoadAddOn

Request the loading of an On-Demand AddOn.

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

Parameters[edit]

Arguments[edit]

(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[edit]

loaded, reason
loaded
Flag - Indicates if the AddOn was loaded, 1 if it is, nil if it is not.
reason
String - The reason why the AddOn cannot be loaded. This is nil if the addon was loaded, otherwise it contains a code indicating the reason.

Usage[edit]

local loaded, reason = LoadAddOn("MyOtherAddOn")

if not loaded then
  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
else
  -- do something special
end

Details[edit]

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[edit]

(taken from FrameXML\GlobalStrings.lua)
(they are all prefixed with "ADDON_", use getglobal("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.
INTERACE_VERSION
-- Unknown, presumably the interface version in the .toc file is incorrect