Wowpedia

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

READ MORE

Wowpedia
m (wording)
m (→‎Frame Scripts: they are separate concepts alright)
Line 43: Line 43:
 
Most Vanilla addons still define their frames in XML, since {{api|CreateFrame}}() was only added in [[1.10.0_API_changes_(Iriel)|Patch 1.10]]
 
Most Vanilla addons still define their frames in XML, since {{api|CreateFrame}}() was only added in [[1.10.0_API_changes_(Iriel)|Patch 1.10]]
 
* Parameters like <code>this, event, arg1, arg2, arg3</code> are no longer globals for the script handler. This was changed in [[Patch_4.0.1/API_changes#Breaking_changes|Patch 4.0.1]]<br>They are now passed like so <code>[[UIHANDLER_OnEvent|OnEvent]](self, event, ...)</code> or <code>OnEvent(self, event, someVar1, someVar2, someVar3)</code>
 
* Parameters like <code>this, event, arg1, arg2, arg3</code> are no longer globals for the script handler. This was changed in [[Patch_4.0.1/API_changes#Breaking_changes|Patch 4.0.1]]<br>They are now passed like so <code>[[UIHANDLER_OnEvent|OnEvent]](self, event, ...)</code> or <code>OnEvent(self, event, someVar1, someVar2, someVar3)</code>
* The <code>this</code> parameter was unique to WoW frame scripts. It can generally be replaced with <code>self</code> even though they are separate concepts.
+
* The <code>this</code> parameter was unique to WoW frame scripts. It can generally be replaced with <code>self</code>
   
 
===Quick fix===
 
===Quick fix===

Revision as of 23:01, 9 September 2019

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.

If you don't have an error handling addon yet, get BugSack or Swatter or enable CVar scriptErrors. Any errors for .xml files are logged to \_classic_\Logs\FrameXML.log

See also Patch 1.13.2/API changes.

Globe

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 Globe: check-classic

For example: https://www.townlong-yak.com/globe/#h:2a8385bff94e98a6bad8f5f09b45a148-reads

## Interface: 100206
## Globe: check-classic

API

There is a list of Classic-specific API and a complete list of Classic API.

The TOC version is 11302

You can use the WOW_PROJECT_ID global variable to write conditional code for classic vs BfA.

old: PlaySound("igMainMenuOptionCheckBoxOn")
new: PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
old: PlaySoundFile("Sound/Spells/LevelUp.ogg")
new: PlaySoundFile(569593)

Maps

Maps were reworked in Patch 8.0.1 and the stateful API was changed to be stateless.

Combat Log

The combat log was reworked in Patch 2.4.0

Frame Scripts

Most Vanilla addons still define their frames in XML, since CreateFrame() was only added in Patch 1.10

  • Parameters like this, event, arg1, arg2, arg3 are 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)
  • The this parameter was unique to WoW frame scripts. It can generally be replaced with self

Quick fix

There are multiple ways to handle frame scripts in XML. For simplicity's sake we will only describe a quick fix in blue text.

  • Lua
function SomeAddon_OnLoad(self)
	self:RegisterEvent("ADDON_LOADED")
end

function SomeAddon_OnEvent(self, event, addon)
	print(self, event, addon)
end
  • XML
<Frame name="SomeAddon">
	<Scripts>
		<OnLoad>
			SomeAddon_OnLoad(self)
		</OnLoad>
		<OnEvent>
			SomeAddon_OnEvent(self, event, ...)
		</OnEvent>
	</Scripts>
</Frame>

Lua only

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)