Files
pfQuest xpGuideandClaude Sonnet 5.5 ef2f4f34b3 pfQuest xpGuide 1.0.0
A leveling guide for WoW 1.12 players of pfQuest, based on Easy Route by stealthzi (MIT).
See README.md and CHANGES.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XfR1apt9f3R7SxBKB2FF2D
2026-11-16 14:47:43 +08:00

465 lines
24 KiB
Lua

-- Headless WoW 1.12 stand-in for running pfQuest_xpGuide under texlua (Lua 5.3).
-- Usage: texlua wow.lua <addon dir> <race> <class> <level> <mode> [scenario]
local ADDON = arg[1]
local RACE, CLASS, LEVEL, MODE = arg[2] or "Human", arg[3] or "WARRIOR", tonumber(arg[4] or "1"), arg[5] or "casual"
local SCEN = arg[6] or "walk"
---------------------------------------------------------------- Lua 5.0 shims
L53 = { select = select, unpack = table.unpack, mtype = math.type, toint = math.tointeger, match = string.match, gmatch = string.gmatch, gsub = string.gsub, xpcall = xpcall }
local select, mtype, toint = select, math.type, math.tointeger
table.getn = function(t) if type(t.n) == "number" then return t.n end return #t end
table.setn = function() end
string.gfind = string.gmatch
math.mod = math.fmod
unpack = table.unpack
loadstring = load
getn = table.getn
tinsert, tremove = table.insert, table.remove
strfind, strsub, strlen, strlower, strupper, format, gsub, strrep = string.find, string.sub, string.len, string.lower, string.upper, string.format, string.gsub, string.rep
floor, ceil, abs, max, min, sqrt, mod = math.floor, math.ceil, math.abs, math.max, math.min, math.sqrt, math.fmod
foreach = function(t, f) for k, v in pairs(t) do local r = f(k, v) if r then return r end end end
-- 5.0's tostring/number formatting: 5.3 prints 1.0 for floats; 5.0 prints 1.
local rawtostring = tostring
tostring = function(v) if mtype(v) == "float" and v == math.floor(v) and v > -1e15 and v < 1e15 then return string.format("%d", v) end return rawtostring(v) end
local rawconcat = table.concat
-- integer division in 5.3 string concat of floats: "1.0" -> fix via metatable is impossible; patch .. by converting in string.format users only.
local rawformat = string.format
string.format = function(f, ...)
local a = { ... }
for i = 1, select("#", ...) do if mtype(a[i]) == "float" and a[i] == math.floor(a[i]) then a[i] = toint(a[i]) or a[i] end end
return rawformat(f, L53.unpack(a, 1, select("#", ...)))
end
format = string.format
---------------------------------------------------------------- world state
W = {
race = RACE, class = CLASS, level = LEVEL, xp = 0, money = 1000, zone = "Elwynn Forest", sub = "", x = 0.5, y = 0.5,
time = 1000, log = {}, prints = {}, unknown = {}, errors = {},
}
local ALLY = { Human = 1, Dwarf = 1, Gnome = 1, NightElf = 1, HighElf = 1 }
local RACE_NAME = { NightElf = "Night Elf", Scourge = "Undead", HighElf = "High Elf" }
local START_ZONE = { Human = "Elwynn Forest", Dwarf = "Dun Morogh", Gnome = "Dun Morogh", NightElf = "Teldrassil", Orc = "Durotar",
Troll = "Durotar", Tauren = "Mulgore", Scourge = "Tirisfal Glades", HighElf = "Eversong Woods", Goblin = "Blackstone Island" }
W.zone = os.getenv("ZONE") or START_ZONE[RACE] or "Elwynn Forest"
---------------------------------------------------------------- frames
local frames = {}
local allFrames = {}
local Widget = {}
local function NewObj(kind, name, parent)
local o = { _regions = {}, _kind = kind, _name = name, _parent = parent, _shown = (kind ~= "Frame" or name == nil or true), _scripts = {}, _events = {}, _text = "", _w = 100, _h = 20, _checked = nil, _value = 0, _children = {} }
setmetatable(o, { __index = function(t, k)
local m = Widget[k]
if m then return m end
-- any other method (WoW methods are capitalised): no-op returning nil; plain fields stay nil
if type(k) == "string" and k:find("^%u") then return function() return nil end end
return nil
end })
if name then _G[name] = o; frames[name] = o end
if parent and type(parent) == "table" and parent._children then table.insert(parent._children, o) end
return o
end
Widget.SetScript = function(s, k, f) s._scripts[k] = f end
Widget.GetScript = function(s, k) return s._scripts[k] end
Widget.HasScript = function() return true end
Widget.RegisterEvent = function(s, e) s._events[e] = true end
Widget.UnregisterEvent = function(s, e) s._events[e] = nil end
Widget.UnregisterAllEvents = function(s) s._events = {} end
Widget.Show = function(s) local was = s._shown; s._shown = true; if not was and s._scripts.OnShow then local t = this; this = s; s._scripts.OnShow(); this = t end end
Widget.Hide = function(s) local was = s._shown; s._shown = false; if was and s._scripts.OnHide then local t = this; this = s; s._scripts.OnHide(); this = t end end
Widget.IsShown = function(s) return s._shown end
Widget.IsVisible = function(s) return s._shown end
Widget.SetText = function(s, t) s._text = t end
Widget.GetText = function(s) return s._text end
Widget.SetWidth = function(s, v) s._w = v end
Widget.SetHeight = function(s, v) s._h = v end
Widget.GetWidth = function(s) return s._w end
Widget.GetHeight = function(s) return s._h end
Widget.GetStringWidth = function(s)
-- what shows: colour codes take no room
local t = L53.gsub(L53.gsub(tostring(s._text or ""), "|c%x%x%x%x%x%x%x%x", ""), "|r", "")
return string.len(t) * 6
end
Widget.GetTextWidth = Widget.GetStringWidth
Widget.GetName = function(s) return s._name end
Widget.GetParent = function(s) return s._parent end
Widget.GetObjectType = function(s) return s._kind end
Widget.IsObjectType = function(s, k) return s._kind == k end
Widget.GetChildren = function(s) return L53.unpack(s._children) end
Widget.GetNumChildren = function(s) return #s._children end
Widget.GetRegions = function(s) return L53.unpack(s._regions) end
Widget.SetChecked = function(s, v) s._checked = v end
Widget.GetChecked = function(s) return s._checked end
Widget.SetValue = function(s, v) s._value = v end
Widget.GetValue = function(s) return s._value end
Widget.GetEffectiveScale = function() return 1 end
Widget.GetScale = function() return 1 end
Widget.GetCenter = function() return 500, 400 end
Widget.GetLeft = function() return 400 end
Widget.GetRight = function() return 600 end
Widget.GetTop = function() return 500 end
Widget.GetBottom = function() return 300 end
Widget.SetPoint = function(s, p, rel, rp, x, y)
s._points = s._points or {}
if type(rel) == "number" then rel, rp, x, y = s._parent, p, rel, rp end
if rel == nil then rel = s._parent end
if type(rel) == "string" then rel = _G[rel] end
for i, q in ipairs(s._points) do if q[1] == p then table.remove(s._points, i) break end end
table.insert(s._points, { p, rel, rp or p, x or 0, y or 0 })
end
Widget.ClearAllPoints = function(s) s._points = {} end
Widget.GetPoint = function(s, i) local q = s._points and s._points[i or 1] if not q then return nil end return q[1], q[2], q[3], q[4], q[5] end
Widget.GetNumPoints = function(s) return s._points and #s._points or 0 end
Widget.SetFrameLevel = function(s, l) s._level = l end
Widget.GetFrameLevel = function(s) if s._level then return s._level end local p = s._parent if p and p.GetFrameLevel then return p:GetFrameLevel() + 1 end return 1 end
Widget.GetFrameStrata = function() return "MEDIUM" end
Widget.GetFont = function() return "Fonts\\FRIZQT__.TTF", 12, "" end
Widget.GetTextColor = function() return 1, 1, 1, 1 end
Widget.GetAlpha = function() return 1 end
Widget.GetFacing = function() return 0 end
Widget.GetModel = function() return "" end
Widget.NumLines = function() return 0 end
Widget.IsMouseOver = function() return false end
Widget.GetMinMaxValues = function() return 0, 100 end
Widget.GetVerticalScroll = function(s) return s._vscroll or 0 end
Widget.SetVerticalScroll = function(s, v) s._vscroll = v end
Widget.GetVerticalScrollRange = function() return 0 end
Widget.GetNumber = function() return 0 end
Widget.HasFocus = function() return false end
Widget.CreateFontString = function(s, name, layer, tmpl) local o = NewObj("FontString", name, nil); o._parent = s; table.insert(s._regions, o); return o end
Widget.CreateTexture = function(s, name, layer) local o = NewObj("Texture", name, nil); o._parent = s; o._layer = layer; table.insert(s._regions, o); return o end
Widget.SetTexture = function(s, p) s._path = p end
Widget.GetTexture = function(s) return s._path end
Widget.SetFont = function(s, f, size, flags) if not f then error("SetFont without a font") end s._font, s._size, s._flags = f, size, flags end
Widget.GetFont = function(s) return s._font or "Fonts\\FRIZQT__.TTF", s._size or 12, s._flags or "" end
local function texSetter(field) return function(s, p) if type(p) == "table" then s[field] = p return end
if not s[field] then local t = NewObj("Texture", nil, nil); t._parent = s; s[field] = t end s[field]._path = p end end
Widget.SetNormalTexture = texSetter("_normal")
Widget.SetHighlightTexture = texSetter("_hl")
Widget.SetPushedTexture = texSetter("_pushed")
Widget.SetDisabledTexture = texSetter("_disabled")
Widget.Disable = function(s) s._off = true end
Widget.Enable = function(s) s._off = nil end
Widget.IsEnabled = function(s) return (not s._off) and 1 or nil end
Widget.GetNormalTexture = function(s) return s._normal end
Widget.GetHighlightTexture = function(s) return s._hl end
Widget.GetPushedTexture = function(s) return s._pushed end
Widget.SetBackdrop = function(s, b) s._backdrop = b end
Widget.GetBackdrop = function(s) return s._backdrop end
Widget.SetBackdropColor = function(s, r, g, b, a) s._bgc = { r, g, b, a } end
Widget.SetBackdropBorderColor = function(s, r, g, b, a) s._bdc = { r, g, b, a } end
Widget.GetBackdropBorderColor = function(s) local c = s._bdc or { 1, 1, 1, 1 } return c[1], c[2], c[3], c[4] end
Widget.SetTextColor = function(s, r, g, b) s._tc = { r, g, b } end
Widget.SetVertexColor = function(s, r, g, b, a) s._vc = { r, g, b, a } end
Widget.GetFontString = function(s) s._fs = s._fs or NewObj("FontString", nil, s) return s._fs end
Widget.GetScrollChild = function(s) return s._scrollChild end
Widget.SetScrollChild = function(s, c) s._scrollChild = c end
function CreateFrame(kind, name, parent, template)
local f = NewObj(kind, name, parent)
table.insert(allFrames, f)
if template == "UIPanelButtonTemplate" then f:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up"); f:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight") end
if template == "UIPanelCloseButton" then f:SetNormalTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Up"); f._w, f._h = 32, 32 end
if template == "UICheckButtonTemplate" then f:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up") end
if template == "InputBoxTemplate" and name then local t = f:CreateTexture(name .. "Left") t:SetTexture("Interface\\Common\\Common-Input-Border") end
if name and kind == "Slider" then
NewObj("FontString", name .. "Text", f); NewObj("FontString", name .. "Low", f); NewObj("FontString", name .. "High", f)
end
if name and kind == "CheckButton" then NewObj("FontString", name .. "Text", f) end
if name and kind == "ScrollFrame" then NewObj("Slider", name .. "ScrollBar", f) end
if name and kind == "EditBox" and template == "InputBoxTemplate" then end
if name and (kind == "Button") and template then local t = f:CreateFontString(name .. "Text") end
return f
end
UIParent = NewObj("Frame", "UIParent")
WorldFrame = NewObj("Frame", "WorldFrame")
Minimap = NewObj("Frame", "Minimap")
GameTooltip = NewObj("GameTooltip", "GameTooltip")
for i = 1, 30 do NewObj("FontString", "GameTooltipTextLeft" .. i); NewObj("FontString", "GameTooltipTextRight" .. i) end
DEFAULT_CHAT_FRAME = NewObj("Frame", "DEFAULT_CHAT_FRAME")
DEFAULT_CHAT_FRAME.AddMessage = function(s, m) table.insert(W.prints, tostring(m)) end
ChatFrame1 = DEFAULT_CHAT_FRAME
for _, n in ipairs({ "QuestLogFrame", "QuestFrame", "GossipFrame", "MerchantFrame", "TaxiFrame", "QuestFrameDetailPanel", "QuestFrameProgressPanel",
"QuestFrameRewardPanel", "QuestFrameGreetingPanel", "ClassTrainerFrame", "WorldMapFrame", "QuestLogListScrollFrame", "QuestLogDetailScrollFrame",
"QuestFrameAcceptButton", "QuestFrameCompleteButton", "QuestFrameCompleteQuestButton", "QuestTitleText", "QuestLogTitleText", "MinimapCluster",
"StaticPopup1", "QuestLogDetailScrollChildFrame", "QuestWatchFrame", "UIErrorsFrame", "QuestLogQuestTitle", "QuestLogObjectivesText",
"GameFontNormal", "GameFontNormalSmall", "GameFontHighlight", "GameFontHighlightSmall", "GameFontNormalLarge", "GameFontDisable", "ChatFontNormal",
"WorldMapButton", "WorldMapDetailFrame", "MinimapBackdrop", "GameFontGreen", "GameFontRed", "GameFontWhite", "GameFontHighlightLarge", "NumberFontNormal", "ItemRefTooltip", "ShoppingTooltip1" }) do
NewObj("Frame", n)
end
for _, n in ipairs({ "QuestFrameDetailPanel", "QuestFrameProgressPanel", "QuestFrameRewardPanel", "QuestFrameGreetingPanel", "QuestFrame", "GossipFrame",
"MerchantFrame", "TaxiFrame", "ClassTrainerFrame", "WorldMapFrame", "QuestLogFrame", "StaticPopup1" }) do _G[n]._shown = false end
for i = 1, 30 do NewObj("Button", "QuestLogTitle" .. i); NewObj("Button", "GossipTitleButton" .. i); NewObj("Button", "QuestTitleButton" .. i) end
QUESTS_DISPLAYED = 6
STANDARD_TEXT_FONT = "Fonts\\FRIZQT__.TTF"
MAX_QUESTLOG_QUESTS = 20
NUMGOSSIPBUTTONS = 32
StaticPopupDialogs = {}
UISpecialFrames = {}
SlashCmdList = {}
RAID_CLASS_COLORS = setmetatable({}, { __index = function() return { r = 1, g = 1, b = 1 } end })
ChatTypeInfo = setmetatable({}, { __index = function() return { r = 1, g = 1, b = 1 } end })
ITEM_QUALITY_COLORS = setmetatable({}, { __index = function() return { r = 1, g = 1, b = 1, hex = "|cffffffff" } end })
---------------------------------------------------------------- API
this, event = nil, nil
function GetTime() return W.time end
function time() return 1700000000 + math.floor(W.time) end
date = os.date
function UnitName(u) if u == "player" then return "Tester" end return nil end
function UnitRace(u) if u == "player" then return RACE_NAME[W.race] or W.race, W.race end end
function UnitClass(u) if u == "player" then return W.class:sub(1, 1) .. W.class:sub(2):lower(), W.class end end
function UnitFactionGroup(u) if u == "player" then if ALLY[W.race] then return "Alliance", "Alliance" end return "Horde", "Horde" end end
function UnitLevel(u) if u == "player" then return W.level end return 0 end
function UnitXP() return W.xp end
function UnitXPMax() return 1000 end
function UnitHealth() return 100 end
function UnitHealthMax() return 100 end
function UnitMana() return 100 end
function UnitManaMax() return 100 end
function UnitExists(u) return u == "player" end
function UnitIsPlayer(u) return u == "player" end
function UnitIsDead() return false end
function UnitIsDeadOrGhost() return false end
function UnitAffectingCombat() return false end
function UnitOnTaxi() return false end
function UnitSex() return 2 end
function UnitCanAttack() return false end
function UnitReaction() return 4 end
function UnitClassification() return "normal" end
function UnitCreatureType() return "Beast" end
function UnitPlayerControlled() return false end
function UnitIsUnit(a, b) return a == b end
function UnitBuff() return nil end
function UnitDebuff() return nil end
function UnitIsTapped() return false end
function GetRealmName() return "TestRealm" end
function GetMoney() return W.money end
function GetZoneText() return W.zone end
function GetRealZoneText() return W.zone end
function GetSubZoneText() return W.sub end
function GetMinimapZoneText() return W.sub ~= "" and W.sub or W.zone end
function GetPlayerMapPosition() return W.x, W.y end
function SetMapToCurrentZone() end
function GetCurrentMapZone() return 1 end
function GetCurrentMapContinent() return 1 end
function GetMapZones() return "Elwynn Forest" end
function GetMapContinents() return "Kalimdor", "Eastern Kingdoms" end
function GetBindLocation() return "Goldshire" end
function GetNumPartyMembers() return 0 end
function GetNumRaidMembers() return 0 end
function IsInInstance() return nil end
function IsShiftKeyDown() return nil end
function IsControlKeyDown() return nil end
function IsAltKeyDown() return nil end
function GetCursorPosition() return 0, 0 end
function GetScreenWidth() return 1024 end
function GetScreenHeight() return 768 end
function PlaySound() end
function PlaySoundFile() end
function GetLocale() return "enUS" end
function GetBuildInfo() return "1.12.1", "5875", "Sep 19 2006", 11200 end
function GetCVar() return nil end
function SetCVar() end
function GetFramerate() return 60 end
function GetNetStats() return 0, 0, 50 end
function InCombatLockdown() return nil end
function IsAddOnLoaded(n) return nil end
function GetAddOnInfo() return nil end
function GetNumAddOns() return 0 end
function GetQuestGreenRange() return 8 end
function GetContainerNumSlots(b) if b == 0 then return 16 end return 0 end
function GetContainerItemLink() return nil end
function GetContainerItemInfo() return nil end
function GetContainerItemCooldown() return 0, 0, 0 end
function GetInventoryItemLink() return nil end
function GetInventorySlotInfo() return 1 end
function GetItemInfo() return nil end
function GetItemQualityColor() return 1, 1, 1, "|cffffffff" end
function GetNumTaxiNodes() return 0 end
function NumTaxiNodes() return 0 end
function TaxiNodeName() return nil end
function TaxiNodeGetType() return "NONE" end
function TaxiNodeCost() return 0 end
function TaxiNodePosition() return 0, 0 end
function GetNumGossipOptions() return 0 end
function GetGossipOptions() return nil end
function GetGossipAvailableQuests() return nil end
function GetGossipActiveQuests() return nil end
function GetNumAvailableQuests() return 0 end
function GetNumActiveQuests() return 0 end
function GetTitleText() return "" end
function GetQuestText() return "" end
function GetObjectiveText() return "" end
function GetProgressText() return "" end
function GetRewardText() return "" end
function GetNumQuestChoices() return 0 end
function GetNumQuestRewards() return 0 end
function GetQuestMoneyToGet() return 0 end
function GetQuestReward() end
function IsQuestCompletable() return nil end
function CanMerchantRepair() return nil end
function GetRepairAllCost() return 0, nil end
function GetMerchantNumItems() return 0 end
function GetNumSkillLines() return 0 end
function GetSpellName() return nil end
function GetNumSpellTabs() return 0 end
function HasAction() return nil end
function geterrorhandler() return function(m) table.insert(W.errors, m) end end
function seterrorhandler() end
function hooksecurefunc() end
function issecurevariable() return false end
function RegisterForSave() end
function CloseDropDownMenus() W.menuClosed = (W.menuClosed or 0) + 1 end
function ToggleDropDownMenu(level, value, frame) W.menu = {}; if frame and frame._init then frame._init() end end
-- the game's drop-down menu, enough to test: Initialize keeps the builder, ToggleDropDownMenu runs it, W.menu holds the items
W.menu = {}
function UIDropDownMenu_Initialize(frame, fn, kind) if frame then frame._init = fn end end
function UIDropDownMenu_AddButton(info) table.insert(W.menu, info) end
function UIDropDownMenu_SetWidth() end
function UIDropDownMenu_SetText() end
function UIDropDownMenu_SetSelectedValue() end
function UIDropDownMenu_SetSelectedID() end
function ShowUIPanel(f) if f then f._shown = true end end
function HideUIPanel(f) if f then f._shown = false end end
function ToggleWorldMap() end
function StaticPopup_Show() end
function StaticPopup_Hide() end
function UIFrameFadeIn() end
function UIFrameFadeOut() end
function MoneyFrame_Update() end
function SetDesaturation() end
function FauxScrollFrame_GetOffset(f) return (f and f._offset) or 0 end
function FauxScrollFrame_SetOffset(f, o) if f then f._offset = o end end
function FauxScrollFrame_Update() return true end
function FauxScrollFrame_OnVerticalScroll(h, fn) if fn then fn() end end
function getglobal(n) return _G[n] end
function setglobal(n, v) _G[n] = v end
function GetQuestLogSelection() return W.sel or 0 end
function SelectQuestLogEntry(i) W.sel = i end
function GetQuestLogPushable() return nil end
function ExpandQuestHeader() end
function CollapseQuestHeader() end
function QuestLog_Update() end
function QuestLog_SetSelection(i) W.sel = i end
function GetQuestLogQuestText() local q = W.log[W.sel or 0] return "", (q and q.ask) or "" end
function GetQuestLogRewardMoney() return 0 end
function IsCurrentQuestFailed() return nil end
function GetNumQuestWatches() return 0 end
function IsQuestWatched() return nil end
function AddQuestWatch() end
function RemoveQuestWatch() end
function GetQuestLogTimeLeft() return nil end
-- Quest log: W.log = { {title=, level=, complete=, objs={ {text=, done=} } } }
function GetNumQuestLogEntries() return #W.log, #W.log end
function GetQuestLogTitle(i)
local q = W.log[i]
if not q then return nil end
return q.title, q.level or 1, q.tag, nil, nil, q.complete and 1 or nil
end
function GetNumQuestLeaderBoards(i) i = i or W.sel local q = W.log[i] return q and #(q.objs or {}) or 0 end
function GetQuestLogLeaderBoard(n, i)
i = i or W.sel
local q = W.log[i]
local o = q and q.objs and q.objs[n]
if not o then return nil end
return o.text, o.type or "monster", o.done and 1 or nil
end
-- Unknown globals: record them, give a function returning nil for API-looking names.
local known = {}
-- not in the plain 1.12 client (ClassicAPI and later clients add them): absent, so addons take their 1.12 paths
local ABSENT = { UnitPosition = true, GetPlayerFacing = true, IsIndoors = true, GetUnitSpeed = true, HookScript = true,
UnitGUID = true, GetQuestLogIndexByID = true, GetMapIDByName = true }
setmetatable(_G, { __index = function(t, k)
if ABSENT[k] then return nil end
if type(k) == "string" and not k:find("^pf") and not k:find("^pfQuest_xpGuide") and not k:find("^arg%d") and k ~= "this" and k ~= "event" and k ~= "arg"
and k:find("^%u%l") and not known[k] then
W.unknown[k] = (W.unknown[k] or 0) + 1
return function() return nil end
end
return nil
end })
---------------------------------------------------------------- event driving
local function Fire(ev, a1, a2, a3)
for _, f in ipairs(allFrames) do
if f._events[ev] and f._scripts.OnEvent then
local keepThis, keepEv = this, event
this, event, arg1, arg2, arg3 = f, ev, a1, a2, a3
local ok, err = L53.xpcall(f._scripts.OnEvent, debug.traceback)
if not ok then table.insert(W.errors, "[" .. ev .. "] " .. tostring(err)) end
this, event = keepThis, keepEv
end
end
end
local function Tick(dt, n)
for _ = 1, (n or 1) do
W.time = W.time + dt
for _, f in ipairs(allFrames) do
local s = f._scripts.OnUpdate
if s and f._shown ~= false then
this, arg1 = f, dt
local ok, err = L53.xpcall(s, debug.traceback)
if not ok then table.insert(W.errors, "[OnUpdate " .. tostring(f._name) .. "] " .. tostring(err)) end
end
end
end
end
W.Fire, W.Tick = Fire, Tick
W.frames = allFrames
---------------------------------------------------------------- load the addon
local toc = io.open(ADDON .. "/pfQuest_xpGuide.toc"):read("a")
local tocLines = {}
for line in toc:gmatch("[^\r\n]+") do table.insert(tocLines, line) end
if not os.getenv("LAX") then
local function gone(name) return function() error(name .. " does not exist in Lua 5.0 (WoW 1.12)", 2) end end
string.match = gone("string.match"); string.gmatch = gone("string.gmatch"); _G.select = gone("select")
table.unpack = gone("table.unpack"); table.pack = gone("table.pack"); math.fmod = gone("math.fmod"); math.huge = nil
math.type = gone("math.type"); math.tointeger = gone("math.tointeger"); utf8 = nil; table.move = gone("table.move")
string.gfind = L53.gmatch; math.mod = function(a, b) return a - math.floor(a / b) * b end -- 5.0 math.mod is C fmod; same for positives
-- Lua 5.0's ipairs is its own generator: with a second argument present it takes one step instead of starting a loop.
local sel = L53.select
local function ipairs50(t, ...)
if type(t) ~= "table" then error("bad argument #1 to `ipairs' (table expected, got " .. type(t) .. ")", 2) end
local n = sel("#", ...)
local i = tonumber((...)) or 0
if i == 0 and n == 0 then return ipairs50, t, 0 end
i = i + 1
local v = rawget(t, i)
if v == nil then return end
return i, v
end
ipairs = ipairs50
local rawx = L53.xpcall
xpcall = function(f, h, ...) if L53.select("#", ...) > 0 then error("xpcall with arguments needs Lua 5.2", 2) end return rawx(f, h) end
end
if PRE_ADDONS then PRE_ADDONS() end
for _, line in ipairs(tocLines) do
if not line:find("^##") and line:find("%S") then
local path = ADDON .. "/" .. line:gsub("\\", "/"):gsub("%s+$", "")
local chunk, err = loadfile(path)
if not chunk then error("load " .. path .. ": " .. err) end
local ok, e = L53.xpcall(chunk, debug.traceback)
if not ok then table.insert(W.errors, "[load " .. line .. "] " .. tostring(e)) end
end
end
for k in pairs(_G) do known[k] = true end
local ER = pfQuest_xpGuide
-- start fresh or from a saved db
if W.savedDB then pfQuest_xpGuideDB = W.savedDB end
if PRE_EVENTS then PRE_EVENTS() end
Fire("ADDON_LOADED", "pfQuest_xpGuide")
Fire("VARIABLES_LOADED")
Fire("PLAYER_LOGIN")
Fire("PLAYER_ENTERING_WORLD")
Fire("QUEST_LOG_UPDATE")
if ER.db and MODE then ER.db.mode = MODE end
Tick(0.5, 50)
W.ER = ER
return W