Files
coa-exporter/CoaExporter/Collectors/MysticScrollProbe.lua
T

117 lines
3.8 KiB
Lua

-- CoaExporter - Mystic Scroll API probe + deep dump
-- Purpose: discover what data we can extract about mystic enchants on
-- Ascension's 3.3.5 client. Intentionally over-probes several API
-- signatures; failures are captured so we can see what's available.
CoaExporter = _G.CoaExporter or {}
_G.CoaExporter = CoaExporter
local AE = CoaExporter
local scanner
local function EnsureScanner()
if not scanner then
scanner = CreateFrame("GameTooltip", "CoaExpScrollProbe", nil, "GameTooltipTemplate")
scanner:SetOwner(WorldFrame, "ANCHOR_NONE")
end
return scanner
end
local function TipToLines(tooltipSetup)
local s = EnsureScanner()
s:ClearLines()
tooltipSetup(s)
local out = {}
for i = 1, s:NumLines() do
local left = _G["CoaExpScrollProbeTextLeft" .. i]
if left then
local t = left:GetText()
if t and t ~= "" then table.insert(out, t) end
end
end
return out
end
local function TryCall(fn, ...)
local ok, a, b, c, d, e, f, g = pcall(fn, ...)
if ok then return true, a, b, c, d, e, f, g end
return false, a
end
function AE.CollectMysticScrollProbe()
local result = {
api_surface = {},
slots = {},
enchants = {},
errors = {},
}
if C_MysticEnchant then
for k, v in pairs(C_MysticEnchant) do
if type(v) == "function" then
table.insert(result.api_surface, "C_MysticEnchant." .. k)
end
end
table.sort(result.api_surface)
else
table.insert(result.errors, "C_MysticEnchant global is nil")
end
local numSlots = NUM_MYSTIC_ENCHANT_SLOTS or 12
for i = 1, numSlots do
local slotData = { slot = i }
if C_MysticEnchant and C_MysticEnchant.GetAppliedEnchant then
local ok, spellID = TryCall(C_MysticEnchant.GetAppliedEnchant, "player", i)
if ok and spellID and spellID > 0 then
slotData.spellID = spellID
local name, _, icon = GetSpellInfo(spellID)
slotData.name = name
slotData.icon = icon and (icon:match("Interface\\Icons\\(.+)") or icon):lower() or nil
slotData.tooltip_lines = TipToLines(function(t)
t:SetHyperlink("spell:" .. spellID)
end)
end
end
for _, m in ipairs({ "GetSlotInfo", "GetSlotTier", "GetSlotQuality",
"GetEnchantSlotInfo", "GetSlotType" }) do
if C_MysticEnchant and C_MysticEnchant[m] then
local ok, r1, r2, r3 = TryCall(C_MysticEnchant[m], i)
if ok then
slotData[m] = { r1, r2, r3 }
end
end
end
table.insert(result.slots, slotData)
end
if C_MysticEnchant then
for _, fname in ipairs({
"GetKnownEnchants", "GetUnlockedEnchants", "GetAllEnchants",
"GetEnchants", "GetLearnedEnchants", "GetAvailableEnchants" }) do
if C_MysticEnchant[fname] then
local ok, list = TryCall(C_MysticEnchant[fname], "player")
if ok and type(list) == "table" then
result[fname] = list
end
end
end
end
for _, sd in ipairs(result.slots) do
if sd.spellID and C_MysticEnchant then
for _, m in ipairs({ "GetEnchantInfo", "GetEnchantQuality",
"GetEnchantTier", "GetEnchantDescription" }) do
if C_MysticEnchant[m] then
local ok, r1, r2, r3 = TryCall(C_MysticEnchant[m], sd.spellID)
if ok then
sd[m] = { r1, r2, r3 }
end
end
end
end
end
return result
end
AE._loadedMysticScrollProbe = true