777 lines
36 KiB
Lua
777 lines
36 KiB
Lua
-- aux on the 70334 client: the WoW 1.12 API aux was written for, provided inside aux's own module environments.
|
|
-- Nothing here is written into Blizzard globals (no taint); aux modules resolve globals through OctoAuxCompat first.
|
|
-- Auctions come from the Source (Turtle) server itself through the gateway's private "OctoAux" addon channel:
|
|
-- each request is the exact 1.12 packet, each result page is the server's own rows.
|
|
local G = _G
|
|
local C = {}
|
|
local GII = (G.C_Item and G.C_Item.GetItemInfo) or G.GetItemInfo
|
|
local GIQC = G.GetItemQualityColor or (G.C_Item and G.C_Item.GetItemQualityColor)
|
|
OctoAuxCompat = C
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
-- Lua 5.0 library semantics
|
|
----------------------------------------------------------------------------------------------------------------
|
|
local sizes = setmetatable({}, {__mode = 'k'}) -- explicit table.setn sizes (vararg tables may hold nils)
|
|
local function getn(t)
|
|
local s, n = sizes[t], #t
|
|
if s and s > n then return s end
|
|
return n
|
|
end
|
|
local function setn(t, n)
|
|
if n == 0 or n == #t then sizes[t] = nil else sizes[t] = n end
|
|
end
|
|
local function tinsert(t, pos, v)
|
|
local n = getn(t)
|
|
if v == nil then v, pos = pos, n + 1 else
|
|
for i = n, pos, -1 do t[i + 1] = t[i] end
|
|
end
|
|
t[pos] = v
|
|
if sizes[t] then sizes[t] = n + 1 end
|
|
end
|
|
local function tremove(t, pos)
|
|
local n = getn(t)
|
|
if n == 0 then return end
|
|
pos = pos or n
|
|
local v = t[pos]
|
|
for i = pos, n - 1 do t[i] = t[i + 1] end
|
|
t[n] = nil
|
|
if sizes[t] then setn(t, n - 1) end
|
|
return v
|
|
end
|
|
C.getn, C.setn, C.tinsert, C.tremove = getn, setn, tinsert, tremove
|
|
C.unpack = function(t, i, j) return G.unpack(t, i or 1, j or getn(t)) end
|
|
C.table = setmetatable({getn = getn, setn = setn, insert = tinsert, remove = tremove}, {__index = G.table})
|
|
C.string = setmetatable({gfind = G.string.gmatch}, {__index = G.string})
|
|
C.gfind = G.string.gmatch
|
|
C.math = setmetatable({mod = G.math.fmod}, {__index = G.math})
|
|
C.mod = G.math.fmod
|
|
-- for k, v in t do (Lua 5.0 table iteration; iterator functions pass through)
|
|
function C.__it(x, ...)
|
|
if type(x) == 'table' then return next, x, nil end
|
|
return x, ...
|
|
end
|
|
-- Lua 5.0 implicit vararg table
|
|
function C.__va(...)
|
|
local t = {...}
|
|
t.n = select('#', ...)
|
|
if t.n ~= #t then sizes[t] = t.n end
|
|
return t
|
|
end
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
-- Script handlers: 1.12 passes this / event / arg1..arg9 as globals
|
|
----------------------------------------------------------------------------------------------------------------
|
|
local function errorh(e) G.geterrorhandler()(e) end
|
|
local function run(f, self, event, ...)
|
|
local ot, oe = C.this, C.event
|
|
local o1, o2, o3, o4, o5, o6, o7, o8, o9 = C.arg1, C.arg2, C.arg3, C.arg4, C.arg5, C.arg6, C.arg7, C.arg8, C.arg9
|
|
C.this, C.event = self, event
|
|
C.arg1, C.arg2, C.arg3, C.arg4, C.arg5, C.arg6, C.arg7, C.arg8, C.arg9 = ...
|
|
xpcall(f, errorh)
|
|
C.this, C.event = ot, oe
|
|
C.arg1, C.arg2, C.arg3, C.arg4, C.arg5, C.arg6, C.arg7, C.arg8, C.arg9 = o1, o2, o3, o4, o5, o6, o7, o8, o9
|
|
end
|
|
C.__run = run
|
|
-- 1.12 FauxScrollFrame_OnVerticalScroll(itemHeight, updateFunction) read this/arg1; 70334 takes
|
|
-- (frame, offset, itemHeight, updateFunction). Owner 2026-11-26: scrolling the Post bag list raised a Lua error.
|
|
function C.FauxScrollFrame_OnVerticalScroll(a, b, c, d)
|
|
if type(a) == 'table' then return G.FauxScrollFrame_OnVerticalScroll(a, b, c, d) end
|
|
return G.FauxScrollFrame_OnVerticalScroll(C.this, C.arg1, a, b)
|
|
end
|
|
local function wrap(name, f)
|
|
if name == 'OnEvent' then
|
|
return function(self, event, ...) run(f, self, event, ...) end
|
|
end
|
|
return function(self, ...) run(f, self, C.event, ...) end
|
|
end
|
|
|
|
-- Events the 70334 client does not have: aux's own auction events, raised from OctoAux replies.
|
|
local SYNTHETIC = {AUCTION_ITEM_LIST_UPDATE = true, AUCTION_OWNED_LIST_UPDATE = true, AUCTION_BIDDER_LIST_UPDATE = true,
|
|
NEW_AUCTION_UPDATE = true, AUCTION_HOUSE_SHOW = true, AUCTION_HOUSE_CLOSED = true}
|
|
local synthetic_listeners = {}
|
|
local system = {} -- aux CHAT_MSG_SYSTEM listeners also receive the Source's auction command results
|
|
for e in pairs(SYNTHETIC) do synthetic_listeners[e] = {} end
|
|
local function fire(event, ...)
|
|
for frame in pairs(synthetic_listeners[event] or {}) do
|
|
local h = frame.__aux_scripts and frame.__aux_scripts.OnEvent
|
|
if h then run(h, frame, event, ...) end
|
|
end
|
|
end
|
|
C.__fire = fire
|
|
|
|
local SOUNDS = {
|
|
AuctionWindowOpen = 'AUCTION_WINDOW_OPEN', AuctionWindowClose = 'AUCTION_WINDOW_CLOSE',
|
|
igCharacterInfoTab = 'IG_CHARACTER_INFO_TAB', igMainMenuOptionCheckBoxOn = 'IG_MAINMENU_OPTION_CHECKBOX_ON',
|
|
igMainMenuOptionCheckBoxOff = 'IG_MAINMENU_OPTION_CHECKBOX_OFF', igMainMenuOption = 'IG_MAINMENU_OPTION',
|
|
igMainMenuClose = 'IG_MAINMENU_CLOSE', igMainMenuOpen = 'IG_MAINMENU_OPEN', LOOTWINDOWCOINSOUND = 'LOOT_WINDOW_COIN_SOUND',
|
|
}
|
|
function C.PlaySound(s)
|
|
if type(s) == 'string' then s = SOUNDS[s] and G.SOUNDKIT and G.SOUNDKIT[SOUNDS[s]] end
|
|
if s then G.PlaySound(s) end
|
|
end
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
-- Widgets: 1.12 methods on the frames aux creates (instance fields; Blizzard frames are never modified)
|
|
----------------------------------------------------------------------------------------------------------------
|
|
local function adopt_texture(t)
|
|
if t.__aux then return t end
|
|
t.__aux = true
|
|
local SetTexture, SetGradient = t.SetTexture, t.SetGradient
|
|
function t:SetTexture(a, b, c, d, ...)
|
|
if type(a) == 'number' and b ~= nil then -- 1.12 SetTexture(r, g, b[, a]); a lone number is a file id
|
|
local ok = pcall(self.SetColorTexture, self, a, tonumber(b) or a, tonumber(c) or a, tonumber(d) or 1)
|
|
if not ok and not C.__color_reported then C.__color_reported = true G.print('aux color', a, b, c, d) end
|
|
return
|
|
end
|
|
return SetTexture(self, a, b, c, d, ...)
|
|
end
|
|
function t:SetGradientAlpha(o, r1, g1, b1, a1, r2, g2, b2, a2)
|
|
return SetGradient(self, o, G.CreateColor(r1, g1, b1, a1), G.CreateColor(r2, g2, b2, a2))
|
|
end
|
|
function t:SetGradient(o, r1, g1, b1, r2, g2, b2)
|
|
if type(r1) == 'table' then return SetGradient(self, o, r1, g1) end
|
|
return SetGradient(self, o, G.CreateColor(r1, g1, b1, 1), G.CreateColor(r2, g2, b2, 1))
|
|
end
|
|
return t
|
|
end
|
|
C.__adopt_texture = adopt_texture
|
|
local function adopt_font(o) -- FontString / EditBox: 70334 SetFont needs the flags argument
|
|
if not o or o.__aux_font or not o.SetFont then return o end
|
|
o.__aux_font = true
|
|
local SetFont = o.SetFont
|
|
function o:SetFont(file, size, flags) return SetFont(self, file, size, flags or '') end
|
|
return o
|
|
end
|
|
|
|
local adopt
|
|
local function adopt_children(f)
|
|
if f.GetRegions then
|
|
for _, r in ipairs({f:GetRegions()}) do
|
|
local t = r.GetObjectType and r:GetObjectType()
|
|
if t == 'Texture' then adopt_texture(r) elseif t == 'FontString' then adopt_font(r) end
|
|
end
|
|
end
|
|
end
|
|
adopt = function(f)
|
|
if type(f) ~= 'table' or f.__aux then return f end
|
|
f.__aux = true
|
|
local kind = f.GetObjectType and f:GetObjectType()
|
|
local SetScript, GetScript, HookScript = f.SetScript, f.GetScript, f.HookScript
|
|
if SetScript then
|
|
function f:SetScript(name, h)
|
|
self.__aux_scripts = self.__aux_scripts or {}
|
|
self.__aux_scripts[name] = h
|
|
if h == nil then return SetScript(self, name, nil) end
|
|
if not self:HasScript(name) then return end -- 1.12-only script types (e.g. OnTooltipAddMoney)
|
|
return SetScript(self, name, wrap(name, h))
|
|
end
|
|
function f:GetScript(name)
|
|
if self.__aux_scripts and self.__aux_scripts[name] ~= nil then return self.__aux_scripts[name] end
|
|
return GetScript(self, name)
|
|
end
|
|
function f:HookScript(name, h)
|
|
if not self:HasScript(name) then return end
|
|
return HookScript(self, name, wrap(name, h))
|
|
end
|
|
end
|
|
if f.RegisterEvent then
|
|
local RegisterEvent, UnregisterEvent, UnregisterAllEvents = f.RegisterEvent, f.UnregisterEvent, f.UnregisterAllEvents
|
|
function f:RegisterEvent(e)
|
|
if SYNTHETIC[e] then synthetic_listeners[e][self] = true end
|
|
if e == 'CHAT_MSG_SYSTEM' then system[self] = true end
|
|
if not SYNTHETIC[e] or e == 'AUCTION_HOUSE_SHOW' or e == 'AUCTION_HOUSE_CLOSED' then pcall(RegisterEvent, self, e) end
|
|
end
|
|
function f:UnregisterEvent(e)
|
|
if SYNTHETIC[e] then synthetic_listeners[e][self] = nil end
|
|
if e == 'CHAT_MSG_SYSTEM' then system[self] = nil end
|
|
pcall(UnregisterEvent, self, e)
|
|
end
|
|
function f:UnregisterAllEvents()
|
|
for _, l in pairs(synthetic_listeners) do l[self] = nil end
|
|
system[self] = nil
|
|
return UnregisterAllEvents(self)
|
|
end
|
|
end
|
|
if f.CreateTexture then
|
|
local CreateTexture = f.CreateTexture
|
|
function f:CreateTexture(...) return adopt_texture(CreateTexture(self, ...)) end
|
|
end
|
|
if f.CreateFontString then
|
|
local CreateFontString = f.CreateFontString
|
|
function f:CreateFontString(...) return adopt_font(CreateFontString(self, ...)) end
|
|
end
|
|
if f.GetFontString then
|
|
local GetFontString = f.GetFontString
|
|
function f:GetFontString() return adopt_font(GetFontString(self)) end
|
|
end
|
|
if kind == 'EditBox' then adopt_font(f) end
|
|
if kind == 'SimpleHTML' then
|
|
local SetFont = f.SetFont
|
|
function f:SetFont(tt, file, size, flags) return SetFont(self, tt, file, size, flags or '') end
|
|
local GetFont = f.GetFont
|
|
function f:GetFont(tt) return GetFont(self, tt or 'P') end
|
|
end
|
|
if f.CreateTitleRegion == nil and f.StartMoving then
|
|
function f:CreateTitleRegion()
|
|
self:RegisterForDrag('LeftButton')
|
|
SetScript(self, 'OnDragStart', function(s) if s:IsMovable() then s:StartMoving() end end)
|
|
SetScript(self, 'OnDragStop', function(s) s:StopMovingOrSizing() end)
|
|
return {SetAllPoints = function() end, SetPoint = function() end}
|
|
end
|
|
end
|
|
if f.SetMaxLetters then
|
|
local SetMaxLetters = f.SetMaxLetters
|
|
function f:SetMaxLetters(n) return SetMaxLetters(self, n or 0) end
|
|
end
|
|
for _, part in ipairs({'Normal', 'Pushed', 'Highlight', 'Disabled', 'Checked', 'DisabledChecked'}) do
|
|
local set, clear = f['Set' .. part .. 'Texture'], f['Clear' .. part .. 'Texture']
|
|
if set and clear then
|
|
f['Set' .. part .. 'Texture'] = function(self, t, ...)
|
|
if t == nil then return clear(self) end
|
|
return set(self, t, ...)
|
|
end
|
|
end
|
|
end
|
|
if kind == 'Button' or kind == 'CheckButton' then
|
|
if not f.SetTextColor then
|
|
function f:SetTextColor(...) local fs = self:GetFontString() if fs then fs:SetTextColor(...) end end
|
|
end
|
|
if not f.SetDisabledTextColor then function f:SetDisabledTextColor() end end
|
|
if not f.SetHighlightTextColor then function f:SetHighlightTextColor() end end
|
|
end
|
|
if f.SetMinResize == nil and f.SetResizeBounds then
|
|
function f:SetMinResize(w, h) self.__minw, self.__minh = w, h self:SetResizeBounds(w, h, self.__maxw, self.__maxh) end
|
|
function f:SetMaxResize(w, h) self.__maxw, self.__maxh = w, h self:SetResizeBounds(self.__minw or 0, self.__minh or 0, w, h) end
|
|
end
|
|
if kind == 'GameTooltip' then
|
|
function f:SetAuctionItem(type, index) return C.__tooltip_auction(self, type, index) end
|
|
function f:SetAuctionSellItem() return C.__tooltip_sell(self) end
|
|
local SetHyperlink = f.SetHyperlink
|
|
function f:SetHyperlink(link) return SetHyperlink(self, C.__retail_item(link)) end
|
|
end
|
|
adopt_children(f)
|
|
return f
|
|
end
|
|
C.__adopt = adopt
|
|
|
|
local TEMPLATES = {UIPanelButtonTemplate2 = 'UIPanelButtonTemplate', OptionsCheckButtonTemplate = 'UICheckButtonTemplate',
|
|
UIPanelButtonGrayTemplate = 'UIPanelButtonTemplate', OptionsSliderTemplate = 'UISliderTemplateWithLabels',
|
|
CharacterFrameTabButtonTemplate = 'PanelTabButtonTemplate'}
|
|
local BACKDROP_KINDS = {Frame = true, Button = true, EditBox = true, CheckButton = true, ScrollFrame = true, Slider = true, StatusBar = true}
|
|
function C.CreateFrame(kind, name, parent, template, id)
|
|
if template then template = TEMPLATES[template] or template end
|
|
if BACKDROP_KINDS[kind] and G.BackdropTemplateMixin and not (template and template:find('BackdropTemplate')) then
|
|
template = template and (template .. ',BackdropTemplate') or 'BackdropTemplate'
|
|
end
|
|
return adopt((G.OctoTextSize and G.OctoTextSize.CreateFrame or G.CreateFrame)(kind, name, parent, template, id))
|
|
end
|
|
|
|
-- Frames reached through _G by name (template children such as 'aux.frame12ScrollBar') are adopted on lookup.
|
|
local function adoptable(k, v)
|
|
return type(v) == 'table' and type(k) == 'string' and (k:find('^aux') or k:find('^Aux')) and type(v.GetObjectType) == 'function'
|
|
end
|
|
C._G = setmetatable({}, {
|
|
__index = function(_, k) local v = C[k] if v == nil then v = G[k] end if adoptable(k, v) then adopt(v) end return v end,
|
|
__newindex = function(_, k, v) G[k] = v end,
|
|
})
|
|
function C.getglobal(k) return C._G[k] end
|
|
function C.setglobal(k, v) G[k] = v end
|
|
|
|
-- Dropdowns (owner 2026-11-26, taint.log: "Execution tainted by aux-addon while reading global
|
|
-- UIDROPDOWNMENU_MENU_LEVEL"): Blizzard's UIDropDownMenu keeps its state in shared globals, so every aux
|
|
-- Initialize/AddButton/Toggle wrote them from addon code and tainted every later Blizzard menu. aux dropdowns
|
|
-- (template frames from gui.dropdown, marked __auxdd; __aux already marks every wrapped aux frame) now run on a private list menu: the same 1.12 calls
|
|
-- (Initialize, AddButton, Set/GetSelectedValue, ClearAll, CloseDropDownMenus) never touch Blizzard's
|
|
-- dropdown functions or globals. Non-aux frames still go to Blizzard unchanged.
|
|
local building
|
|
local menu
|
|
local function menu_frame()
|
|
if menu then return menu end
|
|
local ok, f = pcall(G.CreateFrame, 'Frame', nil, G.UIParent, 'TooltipBackdropTemplate')
|
|
menu = ok and f or (G.OctoTextSize and G.OctoTextSize.CreateFrame or G.CreateFrame)('Frame', nil, G.UIParent)
|
|
menu:SetFrameStrata('FULLSCREEN_DIALOG'); menu:SetClampedToScreen(true); menu:EnableMouse(true); menu:Hide()
|
|
menu.buttons = {}
|
|
return menu
|
|
end
|
|
local function label(frame)
|
|
local name = frame:GetName()
|
|
return name and G[name .. 'Text']
|
|
end
|
|
local function refresh(frame)
|
|
local text = label(frame)
|
|
if not text then return end
|
|
for _, item in ipairs(frame.__items or {}) do
|
|
if item.value == frame.__value then text:SetText(item.text); return end
|
|
end
|
|
text:SetText(frame.__value == nil and '' or text:GetText())
|
|
end
|
|
local function populate(frame)
|
|
frame.__items = {}
|
|
building = frame
|
|
run(frame.__init, frame, C.event, 1)
|
|
building = nil
|
|
end
|
|
local function close()
|
|
if menu then menu:Hide(); menu.owner = nil end
|
|
end
|
|
local function open(frame)
|
|
if menu and menu:IsShown() and menu.owner == frame then close(); return end
|
|
populate(frame)
|
|
local m = menu_frame()
|
|
m.owner = frame
|
|
local width, height = math.max(frame:GetWidth() - 10, 80), 16
|
|
for i, item in ipairs(frame.__items) do
|
|
local b = m.buttons[i]
|
|
if not b then
|
|
b = (G.OctoTextSize and G.OctoTextSize.CreateFrame or G.CreateFrame)('Button', nil, m)
|
|
b:SetHeight(height)
|
|
b:SetHighlightTexture('Interface\\QuestFrame\\UI-QuestTitleHighlight', 'ADD')
|
|
b.text = b:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall')
|
|
b.text:SetPoint('LEFT', 8, 0); b.text:SetJustifyH('LEFT')
|
|
b.check = b:CreateTexture(nil, 'OVERLAY')
|
|
b.check:SetTexture('Interface\\Buttons\\UI-CheckBox-Check'); b.check:SetSize(14, 14); b.check:SetPoint('RIGHT', -4, 0)
|
|
b:SetScript('OnClick', function(self)
|
|
local owner, entry = m.owner, self.item
|
|
close()
|
|
if entry and entry.func then run(entry.func, self, C.event, entry.arg1, entry.arg2) end
|
|
if owner then refresh(owner) end
|
|
end)
|
|
m.buttons[i] = b
|
|
end
|
|
b.item = item; b.value = item.value; b.arg1 = item.arg1; b.arg2 = item.arg2
|
|
b.text:SetText(item.text or '')
|
|
b.check:SetShown(item.value ~= nil and item.value == frame.__value)
|
|
b:ClearAllPoints(); b:SetPoint('TOPLEFT', 4, -6 - (i - 1) * height); b:SetPoint('RIGHT', -4, 0)
|
|
b:Show()
|
|
end
|
|
for i = #frame.__items + 1, #m.buttons do m.buttons[i]:Hide() end
|
|
m:SetSize(width, #frame.__items * height + 12)
|
|
m:ClearAllPoints(); m:SetPoint('TOPLEFT', frame, 'BOTTOMLEFT', 6, 2)
|
|
m:Show()
|
|
end
|
|
function C.__aux_dropdown(frame)
|
|
frame.__auxdd = true
|
|
local button = frame.button or (frame:GetName() and G[frame:GetName() .. 'Button'])
|
|
if button then
|
|
button:SetScript('OnMouseDown', nil)
|
|
button:SetScript('OnClick', function() open(frame) end)
|
|
end
|
|
frame:HookScript('OnHide', function() if menu and menu.owner == frame then close() end end)
|
|
end
|
|
function C.UIDropDownMenu_AddButton(info, level)
|
|
if building then
|
|
local items = building.__items
|
|
items[#items + 1] = {text = info.text, value = info.value, func = info.func, arg1 = info.arg1, arg2 = info.arg2}
|
|
return
|
|
end
|
|
if info and type(info.func) == 'function' and not info.__aux then
|
|
local f = info.func
|
|
info.func = function(button, a1, a2, checked) run(f, button, C.event, a1, a2, checked) end
|
|
end
|
|
return G.UIDropDownMenu_AddButton(info, level)
|
|
end
|
|
function C.UIDropDownMenu_Initialize(frame, init, ...)
|
|
if frame and frame.__auxdd then frame.__init = init; populate(frame); refresh(frame); return end
|
|
return G.UIDropDownMenu_Initialize(frame, function(self, level, menuList) run(init, self, C.event, level, menuList) end, ...)
|
|
end
|
|
function C.UIDropDownMenu_SetSelectedValue(frame, value, ...)
|
|
if frame and frame.__auxdd then frame.__value = value; refresh(frame); return end
|
|
return G.UIDropDownMenu_SetSelectedValue(frame, value, ...)
|
|
end
|
|
function C.UIDropDownMenu_GetSelectedValue(frame)
|
|
if frame and frame.__auxdd then return frame.__value end
|
|
return G.UIDropDownMenu_GetSelectedValue(frame)
|
|
end
|
|
function C.UIDropDownMenu_ClearAll(frame)
|
|
if frame and frame.__auxdd then frame.__value = nil; local t = label(frame); if t then t:SetText('') end; return end
|
|
return G.UIDropDownMenu_ClearAll(frame)
|
|
end
|
|
function C.CloseDropDownMenus(...)
|
|
close()
|
|
end
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
-- Items and links: aux speaks the 1.12 item string item:id:enchant:suffix:unique
|
|
----------------------------------------------------------------------------------------------------------------
|
|
local function split(s)
|
|
local t = {}
|
|
for v in (s .. ':'):gmatch('([^:]*):') do t[#t + 1] = v end
|
|
return t
|
|
end
|
|
-- 1.12 item string / link / id -> 70334 item string (suffix is field 7 after the id there)
|
|
function C.__retail_item(x)
|
|
if type(x) == 'number' then return 'item:' .. x end
|
|
if type(x) ~= 'string' then return x end
|
|
local body = x:match('|Hitem:([^|]+)|h') or x:match('^item:([%-%d:]+)$')
|
|
if not body then return x end
|
|
local f = split(body)
|
|
if #f > 4 then return 'item:' .. body end -- already a 70334 string
|
|
local id, enchant, suffix = f[1], f[2] or '', f[3] or ''
|
|
if enchant == '0' then enchant = '' end
|
|
if suffix == '0' then suffix = '' end
|
|
return 'item:' .. id .. ':' .. enchant .. ':::::' .. suffix
|
|
end
|
|
-- 70334 link -> 1.12 link
|
|
local function link112(link)
|
|
if not link then return end
|
|
local body, name = link:match('|Hitem:([^|]+)|h%[(.-)%]|h')
|
|
if not body then return link end
|
|
local f = split(body)
|
|
if #f <= 4 then return link end
|
|
local color = link:match('^|c(%x%x%x%x%x%x%x%x)')
|
|
if not color then
|
|
local q = select(3, GII('item:' .. f[1])) or 1
|
|
color = select(4, GIQC(q)) or 'ffffffff'
|
|
end
|
|
local n = function(v) return tonumber(v) or 0 end
|
|
return '|c' .. color .. '|Hitem:' .. n(f[1]) .. ':' .. n(f[2]) .. ':' .. n(f[7]) .. ':' .. n(f[8]) .. '|h[' .. name .. ']|h|r'
|
|
end
|
|
C.__link112 = link112
|
|
function C.__retail_link(link) -- 1.12 link -> 70334 link (chat insertion)
|
|
if type(link) ~= 'string' then return link end
|
|
local body = link:match('|Hitem:([^|]+)|h')
|
|
if not body then return link end
|
|
return (link:gsub('|Hitem:[^|]+|h', '|H' .. C.__retail_item('item:' .. body) .. '|h', 1))
|
|
end
|
|
-- 1.12 GetItemInfo: name, itemstring, quality, (min) level, class, subclass, max stack, equip slot, texture
|
|
function C.GetItemInfo(x)
|
|
local s = C.__retail_item(x)
|
|
local name, link, quality, _, min_level, class, subclass, stack, slot, texture = GII(s)
|
|
if not name then return end
|
|
local f = split((link and link:match('|Hitem:([^|]+)|h')) or '')
|
|
local n = function(v) return tonumber(v) or 0 end
|
|
return name, 'item:' .. n(f[1]) .. ':' .. n(f[2]) .. ':' .. n(f[7]) .. ':0', quality, min_level, class, subclass, stack, slot, texture
|
|
end
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
-- Containers (C_Container) with 1.12 links; the last picked-up bag slot backs the auction sell slot
|
|
----------------------------------------------------------------------------------------------------------------
|
|
local CC = G.C_Container
|
|
local last_pickup
|
|
function C.GetContainerNumSlots(bag) return CC.GetContainerNumSlots(bag) end
|
|
function C.GetContainerItemLink(bag, slot) return link112(CC.GetContainerItemLink(bag, slot)) end
|
|
function C.GetContainerItemInfo(bag, slot)
|
|
local i = CC.GetContainerItemInfo(bag, slot)
|
|
if not i then return end
|
|
return i.iconFileID, i.stackCount, i.isLocked, i.quality, i.isReadable, i.hasLoot
|
|
end
|
|
function C.PickupContainerItem(bag, slot)
|
|
local had = G.GetCursorInfo()
|
|
CC.PickupContainerItem(bag, slot)
|
|
if not had and G.GetCursorInfo() == 'item' then last_pickup = {bag, slot} else last_pickup = nil end
|
|
end
|
|
function C.SplitContainerItem(bag, slot, count) last_pickup = nil return CC.SplitContainerItem(bag, slot, count) end
|
|
function C.UseContainerItem(bag, slot, ...) return CC.UseContainerItem(bag, slot, ...) end
|
|
function C.GetBagName(bag) -- aux only tests that the bag exists
|
|
local f = CC.GetBagName or G.GetBagName
|
|
if f then return f(bag) end
|
|
if bag < 0 or bag > 4 or (CC.GetContainerNumSlots(bag) or 0) == 0 then return nil end
|
|
return bag == 0 and (G.BACKPACK_TOOLTIP or 'Backpack') or ('Bag ' .. bag)
|
|
end
|
|
function C.ContainerIDToInventoryID(bag) return (CC.ContainerIDToInventoryID or G.ContainerIDToInventoryID)(bag) end
|
|
function C.GetInventoryItemLink(unit, slot) return link112(G.GetInventoryItemLink(unit, slot)) end
|
|
function C.GetMerchantItemLink(i) return link112(G.GetMerchantItemLink(i)) end
|
|
function C.GetMerchantItemInfo(i) -- 70334: C_MerchantFrame.GetItemInfo returns a table
|
|
if G.GetMerchantItemInfo then return G.GetMerchantItemInfo(i) end
|
|
local info = G.C_MerchantFrame and G.C_MerchantFrame.GetItemInfo(i)
|
|
if not info then return end
|
|
return info.name, info.texture, info.price, info.stackCount, info.numAvailable, info.isPurchasable, info.isUsable, info.hasExtendedCost
|
|
end
|
|
function C.GetLootSlotLink(i) return link112(G.GetLootSlotLink(i)) end
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
-- Auction classes (1.12 AuctionFrame order; Source item class / subclass / inventory type ids)
|
|
----------------------------------------------------------------------------------------------------------------
|
|
local CLASSES = {2, 4, 1, 0, 7, 6, 11, 9, 5, 15}
|
|
local SUBCLASSES = {
|
|
[2] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 13, 14, 15, 16, 18, 19, 20},
|
|
[4] = {0, 1, 2, 3, 4, 6, 7, 8, 9},
|
|
[1] = {0, 1, 2, 3, 4},
|
|
[7] = {0, 1, 2, 3},
|
|
[6] = {2, 3},
|
|
[11] = {2, 3},
|
|
[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
|
|
}
|
|
local ARMOR = {'INVTYPE_HEAD', 'INVTYPE_SHOULDER', 'INVTYPE_CHEST', 'INVTYPE_WAIST', 'INVTYPE_LEGS', 'INVTYPE_FEET', 'INVTYPE_WRIST', 'INVTYPE_HAND'}
|
|
local INVTYPES = { -- armor subclass -> slots
|
|
[0] = {'INVTYPE_HEAD', 'INVTYPE_NECK', 'INVTYPE_BODY', 'INVTYPE_FINGER', 'INVTYPE_TRINKET', 'INVTYPE_HOLDABLE'},
|
|
[1] = {'INVTYPE_HEAD', 'INVTYPE_SHOULDER', 'INVTYPE_CHEST', 'INVTYPE_WAIST', 'INVTYPE_LEGS', 'INVTYPE_FEET', 'INVTYPE_WRIST', 'INVTYPE_HAND', 'INVTYPE_CLOAK'},
|
|
[2] = ARMOR, [3] = ARMOR, [4] = ARMOR,
|
|
}
|
|
local INVTYPE_ID = {INVTYPE_HEAD = 1, INVTYPE_NECK = 2, INVTYPE_SHOULDER = 3, INVTYPE_BODY = 4, INVTYPE_CHEST = 5, INVTYPE_WAIST = 6,
|
|
INVTYPE_LEGS = 7, INVTYPE_FEET = 8, INVTYPE_WRIST = 9, INVTYPE_HAND = 10, INVTYPE_FINGER = 11, INVTYPE_TRINKET = 12, INVTYPE_CLOAK = 16,
|
|
INVTYPE_HOLDABLE = 23}
|
|
local function class_name(id) return (G.C_Item and G.C_Item.GetItemClassInfo or G.GetItemClassInfo)(id) end
|
|
local function subclass_name(c, s) return (G.C_Item and G.C_Item.GetItemSubClassInfo or G.GetItemSubClassInfo)(c, s) end
|
|
function C.GetAuctionItemClasses()
|
|
local t = {}
|
|
for i, id in ipairs(CLASSES) do t[i] = class_name(id) or ('Class ' .. id) end
|
|
return G.unpack(t)
|
|
end
|
|
function C.GetAuctionItemSubClasses(index)
|
|
local c = CLASSES[index]
|
|
if not c or not SUBCLASSES[c] then return end
|
|
local t = {}
|
|
for i, s in ipairs(SUBCLASSES[c]) do t[i] = subclass_name(c, s) or ('Subclass ' .. s) end
|
|
return G.unpack(t)
|
|
end
|
|
function C.GetAuctionInvTypes(class_index, subclass_index)
|
|
if CLASSES[class_index] ~= 4 then return end
|
|
local list = INVTYPES[SUBCLASSES[4][subclass_index or 0] or -1]
|
|
if list then return G.unpack(list) end
|
|
end
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
-- OctoAux transport
|
|
----------------------------------------------------------------------------------------------------------------
|
|
local PREFIX = 'OctoAux'
|
|
G.C_ChatInfo.RegisterAddonMessagePrefix(PREFIX)
|
|
local function send(text) G.C_ChatInfo.SendAddonMessage(PREFIX, text, 'WHISPER', G.UnitName('player')) end
|
|
|
|
local pages = {list = {rows = {}, total = 0}, owner = {rows = {}, total = 0}, bidder = {rows = {}, total = 0}}
|
|
local KIND = {Q = 'list', O = 'owner', I = 'bidder'}
|
|
local EVENT = {list = 'AUCTION_ITEM_LIST_UPDATE', owner = 'AUCTION_OWNED_LIST_UPDATE', bidder = 'AUCTION_BIDDER_LIST_UPDATE'}
|
|
local incoming = {}
|
|
local current -- page being received (the gateway sends H, R..., E contiguously)
|
|
local list_pending, next_list = false, 0
|
|
local my_guid_low = 0
|
|
local function my_low()
|
|
if my_guid_low == 0 then
|
|
local g = G.UnitGUID('player')
|
|
my_guid_low = g and tonumber(g:match('%-(%x+)$') or '0', 16) or 0
|
|
end
|
|
return my_guid_low
|
|
end
|
|
C.__pages = pages
|
|
|
|
local waiting = {} -- committed pages whose item data is still loading
|
|
local function item_ready(entry) return GII(entry) ~= nil end
|
|
local function commit(kind, page)
|
|
pages[kind] = page
|
|
if kind == 'list' then list_pending = false end
|
|
fire(EVENT[kind])
|
|
end
|
|
local loader = (G.OctoTextSize and G.OctoTextSize.CreateFrame or G.CreateFrame)('Frame')
|
|
loader:Hide()
|
|
loader:SetScript('OnUpdate', function(self)
|
|
local now = G.GetTime()
|
|
for kind, w in pairs(waiting) do
|
|
local ready = true
|
|
for _, r in ipairs(w.page.rows) do if not item_ready(r.entry) then ready = false break end end
|
|
if ready or now - w.since > 3 then waiting[kind] = nil commit(kind, w.page) end
|
|
end
|
|
if not next(waiting) then self:Hide() end
|
|
end)
|
|
|
|
local AUCTION_ERRORS = {[1] = 'ERR_AUCTION_INVENTORY', [2] = 'ERR_AUCTION_DATABASE_ERROR', [3] = 'ERR_NOT_ENOUGH_MONEY',
|
|
[4] = 'ERR_ITEM_NOT_FOUND', [5] = 'ERR_AUCTION_HIGHER_BID', [7] = 'ERR_AUCTION_BID_INCREMENT', [10] = 'ERR_AUCTION_BID_OWN',
|
|
[13] = 'ERR_RESTRICTED_ACCOUNT'}
|
|
local AUCTION_OK = {[0] = 'ERR_AUCTION_STARTED', [1] = 'ERR_AUCTION_REMOVED', [2] = 'ERR_AUCTION_BID_PLACED'}
|
|
local function system_message(text)
|
|
for frame in pairs(system) do
|
|
local h = frame.__aux_scripts and frame.__aux_scripts.OnEvent
|
|
if h then run(h, frame, 'CHAT_MSG_SYSTEM', text) end
|
|
end
|
|
end
|
|
|
|
local events = (G.OctoTextSize and G.OctoTextSize.CreateFrame or G.CreateFrame)('Frame')
|
|
events:RegisterEvent('CHAT_MSG_ADDON')
|
|
events:SetScript('OnEvent', function(_, _, prefix, text)
|
|
if prefix ~= PREFIX or type(text) ~= 'string' then return end
|
|
local kind, rest = text:match('^(%a);?(.*)$')
|
|
if kind == 'H' then
|
|
local k, _, total = rest:match('^(%a);(%d+);(%d+)$')
|
|
if KIND[k] then current = {rows = {}, total = tonumber(total)} incoming[KIND[k]] = current end
|
|
elseif kind == 'R' then
|
|
local f = split(rest:gsub(';', ':'))
|
|
-- id entry count start min_outbid buyout time_left bidder bid owner enchant random_property suffix charges owner_name
|
|
local name = rest:match('([^;]*)$')
|
|
local row = {id = tonumber(f[1]), entry = tonumber(f[2]), count = tonumber(f[3]), start = tonumber(f[4]), min_outbid = tonumber(f[5]),
|
|
buyout = tonumber(f[6]), time_left = tonumber(f[7]), bidder = tonumber(f[8]), bid = tonumber(f[9]), owner = tonumber(f[10]),
|
|
enchant = tonumber(f[11]), random_property = tonumber(f[12]), suffix = tonumber(f[13]), charges = tonumber(f[14]),
|
|
owner_name = name ~= '' and name or nil}
|
|
if current then tinsert(current.rows, row) end
|
|
elseif kind == 'E' then
|
|
local k = KIND[rest]
|
|
local page = k and incoming[k]
|
|
if k then incoming[k] = nil end
|
|
current = nil
|
|
if page then
|
|
local ready = true
|
|
for _, r in ipairs(page.rows) do
|
|
if not item_ready(r.entry) then ready = false if G.C_Item and G.C_Item.RequestLoadItemDataByID then G.C_Item.RequestLoadItemDataByID(r.entry) end end
|
|
end
|
|
if ready then commit(k, page) else waiting[k] = {page = page, since = G.GetTime()} loader:Show() end
|
|
end
|
|
elseif kind == 'D' then
|
|
local id, item, property = rest:match('^(%d+);(%d+);(%d+)$')
|
|
id, item, property = tonumber(id), tonumber(item), tonumber(property)
|
|
if not id or id == 0 or not item or item == 0 or not property or
|
|
id > 4294967295 or item > 4294967295 or property > 4294967295 then return end
|
|
-- Retire both visible and not-yet-committed bidder pages. A subsequent
|
|
-- normal bidder request fetches fresh source data; no unsolicited query race.
|
|
if current == incoming.bidder then current = nil end
|
|
incoming.bidder, waiting.bidder = nil, nil
|
|
commit('bidder', {rows = {}, total = 0})
|
|
if property >= 2147483648 then property = property - 4294967296 end
|
|
local link = 'item:' .. item .. ':0:0:0:0:0:' .. property .. ':0'
|
|
local name = GII and GII(link) or ('item ' .. item)
|
|
-- Exact 1.12 ERR_AUCTION_REMOVED_S (patch-5 GlobalStrings.lua).
|
|
local message = string.format('Your auction of %s has been cancelled by the seller.', name or ('item ' .. item))
|
|
system_message(message)
|
|
if G.DEFAULT_CHAT_FRAME then G.DEFAULT_CHAT_FRAME:AddMessage(message) end
|
|
elseif kind == 'A' then
|
|
local _, action, err = rest:match('^(%d+);(%d+);(%d+)')
|
|
action, err = tonumber(action), tonumber(err)
|
|
if err == 0 then
|
|
local msg = C[AUCTION_OK[action] or '']
|
|
if msg then system_message(msg) end
|
|
if action == 0 then fire('NEW_AUCTION_UPDATE') end
|
|
else
|
|
local msg = C[AUCTION_ERRORS[err] or ''] or C.ERR_AUCTION_DATABASE_ERROR
|
|
if msg then G.UIErrorsFrame:AddMessage(msg, 1, .1, .1) end
|
|
end
|
|
elseif kind == 'X' then
|
|
if rest == 'busy' then list_pending = false next_list = G.GetTime() + .5 end
|
|
end
|
|
end)
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
-- The vanilla auction API
|
|
----------------------------------------------------------------------------------------------------------------
|
|
local function num(v, d) v = tonumber(v) return v and v or d end
|
|
function C.CanSendAuctionQuery() return (not list_pending and G.GetTime() >= next_list) and 1 or nil end
|
|
function C.QueryAuctionItems(name, min_level, max_level, slot_index, class_index, subclass_index, page, usable, quality)
|
|
local class = class_index and CLASSES[class_index]
|
|
local subclass = class and subclass_index and SUBCLASSES[class] and SUBCLASSES[class][subclass_index]
|
|
local slot = -1
|
|
if class == 4 and slot_index then
|
|
local list = INVTYPES[subclass or -1]
|
|
local token = list and list[slot_index]
|
|
slot = token and INVTYPE_ID[token] or -1
|
|
end
|
|
name = (name or ''):gsub(';', ' ')
|
|
list_pending, next_list = true, G.GetTime() + .3
|
|
send(G.format('Q;%d;%s;%d;%d;%d;%d;%d;%d;%d', num(page, 0), name, num(min_level, 0), num(max_level, 0), slot, class or -1,
|
|
subclass or -1, (quality and quality >= 0) and quality or -1, usable and 1 or 0))
|
|
end
|
|
function C.GetOwnerAuctionItems(page) send('O;' .. num(page, 0)) end
|
|
function C.GetBidderAuctionItems(page) send('I;' .. num(page, 0)) end
|
|
function C.GetNumAuctionItems(type)
|
|
local p = pages[type or 'list'] or pages.list
|
|
return #p.rows, p.total
|
|
end
|
|
local function row(type, index) local p = pages[type or 'list'] return p and p.rows[index] end
|
|
local function row_item(r) return 'item:' .. r.entry .. ':' .. (r.enchant > 0 and r.enchant or '') .. ':::::' .. (r.random_property ~= 0 and r.random_property or '') end
|
|
function C.GetAuctionItemLink(type, index)
|
|
local r = row(type, index)
|
|
if not r then return end
|
|
local _, link = GII(row_item(r))
|
|
return link112(link)
|
|
end
|
|
function C.GetAuctionItemInfo(type, index)
|
|
local r = row(type, index)
|
|
if not r then return end
|
|
local name, _, quality, _, min_level, _, _, _, _, texture = GII(row_item(r))
|
|
local mine = r.bidder ~= 0 and r.bidder == my_low()
|
|
local high_bidder
|
|
if type == 'owner' then high_bidder = r.bidder ~= 0 and '?' or nil else high_bidder = mine and 1 or nil end
|
|
local owner = r.owner_name
|
|
if type == 'owner' then owner = G.UnitName('player') end
|
|
local usable = (min_level or 0) <= G.UnitLevel('player') and 1 or nil
|
|
return name, texture, r.count, quality, usable, min_level, r.start, r.min_outbid, r.buyout, r.bid, high_bidder, owner, 0
|
|
end
|
|
function C.GetAuctionItemTimeLeft(type, index)
|
|
local r = row(type, index)
|
|
if not r then return end
|
|
local m = r.time_left / 60000
|
|
if m < 30 then return 1 elseif m < 120 then return 2 elseif m < 480 then return 3 end
|
|
return 4
|
|
end
|
|
function C.PlaceAuctionBid(type, index, amount)
|
|
local r = row(type, index)
|
|
if r and amount and amount > 0 then send('B;' .. r.id .. ';' .. G.floor(amount)) end
|
|
end
|
|
function C.CancelAuction(index)
|
|
local r = row('owner', index)
|
|
if r then send('C;' .. r.id) end
|
|
end
|
|
function C.CloseAuctionHouse() if G.C_AuctionHouse then G.C_AuctionHouse.CloseAuctionHouse() end end
|
|
function C.SortAuctionItems() end
|
|
function C.SetAuctionsTabShowing() end
|
|
|
|
-- Sell slot: the bag slot last picked up and put into the slot; StartAuction posts that whole stack.
|
|
local sell_slot
|
|
function C.ClickAuctionSellItemButton()
|
|
if G.GetCursorInfo() == 'item' then
|
|
if last_pickup then sell_slot = last_pickup end
|
|
G.ClearCursor()
|
|
elseif sell_slot then
|
|
CC.PickupContainerItem(sell_slot[1], sell_slot[2])
|
|
last_pickup, sell_slot = sell_slot, nil
|
|
end
|
|
fire('NEW_AUCTION_UPDATE')
|
|
end
|
|
function C.GetAuctionSellItemInfo()
|
|
if not sell_slot then return end
|
|
local i = CC.GetContainerItemInfo(sell_slot[1], sell_slot[2])
|
|
if not i then sell_slot = nil return end
|
|
local name, _, _, _, _, _, _, _, _, _, price = GII(i.hyperlink)
|
|
return name, i.iconFileID, i.stackCount, i.quality, 1, price
|
|
end
|
|
function C.StartAuction(bid, buyout, minutes)
|
|
if not sell_slot then return end
|
|
local guid = G.C_Item.GetItemGUID(G.ItemLocation:CreateFromBagAndSlot(sell_slot[1], sell_slot[2]))
|
|
local hex = guid and guid:match('%-(%x+)$')
|
|
if hex then send(G.format('S;%s;%d;%d;%d', hex, G.floor(bid), G.floor(buyout or 0), minutes or 1440)) end
|
|
sell_slot = nil
|
|
fire('NEW_AUCTION_UPDATE')
|
|
end
|
|
function C.__tooltip_auction(tip, type, index)
|
|
local r = row(type, index)
|
|
if r then tip:SetHyperlink(row_item(r)) end
|
|
end
|
|
function C.__tooltip_sell(tip)
|
|
if sell_slot then tip:SetBagItem(sell_slot[1], sell_slot[2]) end
|
|
end
|
|
function C.__sell_slot() return sell_slot end
|
|
|
|
C.GetItemQualityColor = GIQC
|
|
C.GetItemIcon = G.GetItemIcon or (G.C_Item and G.C_Item.GetItemIconByID)
|
|
|
|
-- The gateway client has no current realm (GetRealmName is empty); aux keys its saved data by realm name.
|
|
function C.GetCVar(name)
|
|
if name == 'realmName' then
|
|
local r = G.GetRealmName and G.GetRealmName()
|
|
return (r and r ~= '') and r or 'Octo'
|
|
end
|
|
return G.GetCVar(name)
|
|
end
|
|
|
|
-- ChatThrottleLib (aux's LFT price sharing) is not loaded: sharing has no channel through the gateway.
|
|
C.ChatThrottleLib = {SendChatMessage = function() end, SendAddonMessage = function() end}
|
|
|
|
-- 1.12 global strings aux matches against; the client's own (localised) value wins whenever it exists.
|
|
local STRINGS_112 = {
|
|
ITEM_SPELL_CHARGES_P1 = '%d Charges', DURABILITY_TEMPLATE = 'Durability %d / %d', ITEM_BIND_ON_PICKUP = 'Binds when picked up',
|
|
ITEM_BIND_QUEST = 'Quest Item', ITEM_SOULBOUND = 'Soulbound', ITEM_CONJURED = 'Conjured Item', ITEM_MIN_LEVEL = 'Requires Level %d',
|
|
ITEM_SPELL_KNOWN = 'Already known', SPELL_REAGENTS = 'Reagents: ', COPPER_PER_GOLD = 10000, COPPER_PER_SILVER = 100,
|
|
GRAY_FONT_COLOR_CODE = '|cff808080', LIGHTYELLOW_FONT_COLOR_CODE = '|cffffff9a', FONT_COLOR_CODE_CLOSE = '|r',
|
|
ERR_AUCTION_STARTED = 'Auction created.', ERR_AUCTION_REMOVED = 'Auction cancelled.', ERR_AUCTION_BID_PLACED = 'Bid accepted.',
|
|
ERR_AUCTION_HIGHER_BID = 'There is already a higher bid on that item.', ERR_AUCTION_BID_OWN = 'You cannot bid on your own auction.',
|
|
ERR_AUCTION_DATABASE_ERROR = 'Internal auction error.', ERR_NOT_ENOUGH_MONEY = "You don't have enough money.",
|
|
ERR_ITEM_NOT_FOUND = 'The item was not found.', ERR_AUCTION_BID_INCREMENT = 'Your bid increment is too small.',
|
|
ERR_AUCTION_INVENTORY = 'You cannot auction that item.', ERR_RESTRICTED_ACCOUNT = 'Restricted account.',
|
|
UIDROPDOWNMENU_MAXBUTTONS = 32, UIDROPDOWNMENU_BUTTON_HEIGHT = 16,
|
|
ITEM_QUALITY0_DESC = 'Poor', ITEM_QUALITY1_DESC = 'Common', ITEM_QUALITY2_DESC = 'Uncommon', ITEM_QUALITY3_DESC = 'Rare',
|
|
ITEM_QUALITY4_DESC = 'Epic', ITEM_QUALITY5_DESC = 'Legendary', ITEM_QUALITY6_DESC = 'Artifact',
|
|
}
|
|
|
|
-- Unknown globals fall back to the 70334 client, then to the 1.12 strings.
|
|
setmetatable(C, {__index = function(_, k)
|
|
local v = G[k]
|
|
if v == nil then return STRINGS_112[k] end
|
|
if adoptable(k, v) then adopt(v) end
|
|
return v
|
|
end})
|