Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!
Porting older addons to Classic
|This article is a World of Warcraft API stub. You can help expand it by editing it.
Addons for Retail will in most cases work on Classic with removal of any non-Classic API. For Vanilla there is a bit more work involved however.
Globe can tell you which API functions/events in an addon have been removed in Classic, if the TOC is set to the Retail version and with
## Interface: 80200 ## Globe: check-classic
The TOC version is
You can use the WOW_PROJECT_ID global variable to write conditional code for classic vs BfA.
- Texture:SetTexture() can no longer set color textures in Patch 7.0.3, use Texture:SetColorTexture(r, g, b [, a]) instead.
- PlaySound() only accepts SoundKitIDs in Patch 7.0.3
old: PlaySound("igMainMenuOptionCheckBoxOn") new: PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
old: PlaySoundFile("Sound/Spells/LevelUp.ogg") new: PlaySoundFile(569593)
Maps were reworked in Patch 8.0.1 and the stateful API was changed to be stateless.
- WorldMapAreaIDs were replaced with UiMapIDs.
- It's no longer needed to call SetMapToCurrentZone() and GetCurrentMapAreaID() to get the current zone UI map, instead use C_Map.GetBestMapForUnit("player")
The combat log was reworked in Patch 2.4.0
- The event payload is returned from CombatLogGetCurrentEventInfo() since Patch 8.0.1
- See COMBAT_LOG_EVENT for details.
- Parameters like
this, event, arg1, arg2, arg3are no longer globals for the script handler. This was changed in Patch 4.0.1
They are now passed like so
OnEvent(self, event, ...)or
OnEvent(self, event, someVar1, someVar2, someVar3)
thisparameter was unique to WoW frame scripts. It can generally be replaced with
selfeven though they are separate concepts.
There are multiple ways to handle frame scripts in XML. For simplicity's sake we will only describe a quick fix in blue text.
function SomeAddon_OnLoad(self) self:RegisterEvent("ADDON_LOADED") end function SomeAddon_OnEvent(self, event, addon) print(self, event, addon) end
<Frame name="SomeAddon"> <Scripts> <OnLoad> SomeAddon_OnLoad(self) </OnLoad> <OnEvent> SomeAddon_OnEvent(self, event, ...) </OnEvent> </Scripts> </Frame>
It's also possible to create a frame and handle the scripts in Lua without use of XML, depending on how simple the addon is.
local function OnEvent(self, event, addon) print(self, event, addon) end local f = CreateFrame("Frame") f:RegisterEvent("ADDON_LOADED") f:SetScript("OnEvent", OnEvent)