(Maps, Combat Log) |
No edit summary |
||
Line 5: | Line 5: | ||
For Vanilla (1.12) however, there is a bit more work involved. |
For Vanilla (1.12) however, there is a bit more work involved. |
||
+ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
==Frame Scripts== |
==Frame Scripts== |
||
+ | 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</code>, <code>event</code> and <code>argN</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]] |
+ | * Parameters like <code>this</code>, <code>event</code> and <code>argN</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]] |
* 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> even though they are separate concepts. |
||
* <code>arg1</code>, <code>arg2</code>, <code>arg3</code>, etc were replaced with the <code>...</code> vararg. See the [[Widget_handlers#Frame|OnEvent]] frame script. |
* <code>arg1</code>, <code>arg2</code>, <code>arg3</code>, etc were replaced with the <code>...</code> vararg. See the [[Widget_handlers#Frame|OnEvent]] frame script. |
||
Line 55: | Line 65: | ||
Object:Bravo() |
Object:Bravo() |
||
Object.Bravo(Object) |
Object.Bravo(Object) |
||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ |
Revision as of 01:15, 18 June 2019
Addons for Retail (8.1.5) can in most cases be easily ported to Classic (1.13.2) with minimal changes and removal of any non-Classic API.
For Vanilla (1.12) however, there is a bit more work involved.
Maps
Maps were reworked in Patch 8.0.1 and the stateful API was changed to be stateless.
- It's no longer needed to call SetMapToCurrentZone() first to get the current zone UI map, instead use C_Map.GetBestMapForUnit()
Combat Log
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.
Frame Scripts
Most Vanilla addons still define their frames in XML, since CreateFrame() was only added in Patch 1.10
- Parameters like
this
,event
andargN
are no longer globals for the script handler. This was changed in Patch 4.0.1 - The
this
parameter was unique to WoW frame scripts. It can generally be replaced withself
even though they are separate concepts. arg1
,arg2
,arg3
, etc were replaced with the...
vararg. See the OnEvent frame script.
Quick fix
There are multiple ways to create frames and handle frame scripts in XML. For simplicity's sake we will only describe a quick fix and a Lua only example.
- Lua
function SomeAddon_OnLoad(frame) frame:RegisterEvent("ADDON_LOADED") end function SomeAddon_OnEvent(frame, event, addon) print(frame, 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.
function f:OnEvent(event, addon) print(self, event, addon) end local f = CreateFrame("Frame") f:RegisterEvent("ADDON_LOADED") f:SetScript("OnEvent", f.OnEvent)
self parameter
For more information, see WowAce: Coding Tips#Methods and Ref Manual: Function Definitions
The following are the same for passing an argument.
function Object:Bravo() end function Object.Bravo(self) end
The following are the same for calling a function.
Object:Bravo() Object.Bravo(Object)