Files

5.8 KiB

Converting a 1.12 (Octo / Turtle) addon to the OctoWoW Forever client

Use this guide to make an addon written for the 1.12 Octo / Turtle WoW client run on the OctoWoW Forever client. The Forever client is a modern 70334 client. The examples come from the pfQuest port (compat/forever.lua in this branch); copy from it freely.

1. Know what changed

Area 1.12 Forever (70334)
Lua 5.0 (table.getn, arg, string.gfind) 5.1 (#t, ..., string.gmatch)
Script handlers globals this, event, arg1..arg9 self, event, ... parameters
Division by zero gives inf raises an error ("Division by zero")
Draw layers also LOW, HIGH, DIALOG, … only BACKGROUND, BORDER, ARTWORK, OVERLAY, HIGHLIGHT
World map WorldMapButton, WorldMapDetailFrame, GetMapZones, GetPlayerMapPosition("player") C_Map with uiMapIDs; the map is a zoomable canvas (WorldMapFrame.ScrollContainer)
Quest log GetQuestLogTitle(i), QuestLogFrame, SetAbandonQuest() C_QuestLog.GetInfo(i), quests are in the map's quest panel, C_QuestLog.SetAbandonQuest()
Objective text "Wildkin slain: 3/8" positional format "%2$d/%3$d %1$s slain"
Skills GetNumSkillLines, GetSkillLineInfo C_SkillInfo (returns a table)
UnitName name name, realm (two values)
Addon messages every prefix arrives only prefixes registered with C_ChatInfo.RegisterAddonMessagePrefix
Guild chat sending without a guild fails silently refused; send server commands (.queststatus) on SAY
Server queries GetItemInfo(id) is a local cache every unknown id is a server request; do not crawl id ranges at login
Blizzard globals free to replace writing them taints secure code (action bars, casting, Exit Game)

2. Never write Blizzard globals

On the modern client, replacing a Blizzard function or table (for example QuestLog_Update = myFunc or WorldMapFrame:SetScript(...)) taints it. Protected actions that run later then fail with "blocked action" errors. Use these instead:

  • hooksecurefunc("Name", fn) or hooksecurefunc(table, "Name", fn) to run code after a Blizzard function;
  • frame:HookScript("OnShow", fn) instead of SetScript on Blizzard frames;
  • your own frames for your own UI, parented to the Blizzard window when they should appear inside it.

For large addons, keep the code unchanged and give it a private environment:

-- compat.lua, loaded first and NOT inside the env
local G = _G
local C = setmetatable({}, { __index = G })   -- reads: private value first, then the real global
myAddonEnv = C
C.this = nil                                     -- 1.12 handler globals live here
C.UnitName = function(u) return (G.UnitName(u)) end  -- 1.12 return shape
-- ...one shim per difference from section 1

Then put setfenv(1, myAddonEnv) in front of the first line of every other Lua file. Line numbers in error messages stay correct. Global writes now go into myAddonEnv and never reach Blizzard code. The converter in this repository's porting/ folder does this automatically from the unmodified addon source. It also flattens XML <Script> includes and rewrites the .toc:

python3 porting/build.py <pfQuest source> <pfQuest-turtle source> <output folder>

To convert another addon, copy porting/, swap forever_compat.lua for your own compat layer (start from pfQuest's: most 1.12 shims are generic) and change the env name (pfQuestEnv) and addon names in build.py.

Things the environment must provide:

  • this/arg1 handlers: wrap CreateFrame so SetScript(name, f) stores a wrapper that sets C.this, C.event and C.arg1..9 before calling f.
  • Missing 1.12 functions: implement them on the modern API. Example: GetNumQuestLogEntries maps to C_QuestLog.GetNumQuestLogEntries. Return the 1.12 shape, because old code unpacks positional returns.
  • Missing frames the addon only decorates (for example QuestLogFrame): create hidden stand-in frames of the same widget type. A Button stand-in is needed if the code sets OnClick.
  • Invalid draw layers: map them in your CreateTexture/CreateFontString wrappers (HIGH → OVERLAY, anything unknown → ARTWORK).

4. Fix the things a shim cannot fix

Some 1.12 behaviour has no API to wrap, so change the source. The pfQuest build applies such edits as small exact patches (PATCHES in build.py). The build stops if a patch no longer matches.

  • x / 0 where 1.12 relied on inf: write w > 0 and z / w or math.huge, or reorder a / (b / c) into a * c / b.
  • table.getn(t) → #t; string.gfind → string.gmatch; vararg arg → local arg = {...}.

5. Map pins

The modern world map zooms and pans. A pin anchored to WorldMapFrame stays where it is while the map moves. Create a pin layer as a child of WorldMapFrame.ScrollContainer.Child and size it to the canvas. Position pins at x * width, -y * height, where x, y are 0..1 zone coordinates (the same coordinates as 1.12). Buttons that belong to the window rather than the map (dropdowns, toggles) go on WorldMapFrame.ScrollContainer, so they do not zoom with the map.

6. Test

  1. Turn on Lua errors: /console scriptErrors 1.
  2. Log in, open every window of the addon, and /reload once. Watch the error count. An error that counts up fast comes from an OnUpdate handler; fix those first.
  3. Do one protected action after using the addon (cast from the action bar, Exit Game). If that fails, the addon still writes a Blizzard global somewhere.

7. Ship

Keep the original LICENSE and credit the authors in your README. Put the addon in its own folder under Interface/AddOns. Set ## Interface: in the .toc to the client's interface number (16001 on Forever).