61 lines
3.1 KiB
Lua
61 lines
3.1 KiB
Lua
-- Source item stat lines the 70334 client cannot compute (Claude lane, 2026-11-22).
|
|
-- 70334 derives item stats from an item-level budget that is zero for poor/common quality and for item levels without
|
|
-- a RandPropPoints row. Those Turtle items (GatewaySourceItemStatData) get their stat, resistance, block and
|
|
-- non-armor-class armor lines inserted into the item tooltip, before Durability/Requires/Equip/Use lines.
|
|
-- The server applies the real values. Same TooltipDataProcessor pre-call route as SourceItemArmor.lua; fails closed.
|
|
local diagnostics = {tooltips = 0, inserted = 0, errors = 0}
|
|
GatewaySourceItemStatsDiagnostics = diagnostics
|
|
local inserted = setmetatable({}, {__mode = "k"})
|
|
|
|
local function public(value)
|
|
if type(issecretvalue) == "function" then
|
|
local ok, hidden = pcall(issecretvalue, value)
|
|
if not ok or hidden then return false end
|
|
end
|
|
return true
|
|
end
|
|
|
|
local STOP = {"^Durability ", "^Requires ", "^Classes: ", "^Races: ", "^Equip: ", "^Use: ", "^Chance on hit: ", "^\""}
|
|
local function stopLine(text)
|
|
if type(text) ~= "string" then return false end
|
|
for _, pattern in ipairs(STOP) do if text:match(pattern) then return true end end
|
|
return false
|
|
end
|
|
|
|
local function prepare(tooltip, data)
|
|
if not public(data) or type(data) ~= "table" or data.type ~= 0 or type(data.id) ~= "number" then return end
|
|
local profile = GatewaySourceItemStatData
|
|
if type(profile) ~= "table" or profile.schemaVersion ~= 1 or profile.locale ~= "enUS" or
|
|
type(GetLocale) ~= "function" or GetLocale() ~= "enUS" or type(profile.items) ~= "table" then return end
|
|
local stats = profile.items[data.id]
|
|
if type(stats) ~= "table" or not public(data.lines) or type(data.lines) ~= "table" or #data.lines > 1024 then return end
|
|
local own = inserted[data]
|
|
if own then
|
|
for i = #data.lines, 1, -1 do if own[data.lines[i]] then table.remove(data.lines, i) end end
|
|
inserted[data] = nil
|
|
end
|
|
local at = #data.lines + 1
|
|
for i, line in ipairs(data.lines) do
|
|
if not public(line) or type(line) ~= "table" or not public(line.leftText) then return end
|
|
if i > 1 and stopLine(line.leftText) then at = i; break end
|
|
if line.leftText and stats[1] and line.leftText == stats[1] then return end -- already present
|
|
end
|
|
own = {}
|
|
for offset, text in ipairs(stats) do
|
|
local line = {type = 0, leftText = text, leftColor = CreateColor and CreateColor(1, 1, 1, 1) or nil, wrapText = false}
|
|
table.insert(data.lines, at + offset - 1, line)
|
|
own[line] = true
|
|
end
|
|
inserted[data] = own
|
|
diagnostics.tooltips = diagnostics.tooltips + 1
|
|
diagnostics.inserted = diagnostics.inserted + #stats
|
|
end
|
|
|
|
pcall(function()
|
|
if type(TooltipDataProcessor) ~= "table" or type(TooltipDataProcessor.AddTooltipPreCall) ~= "function" or
|
|
type(Enum) ~= "table" or type(Enum.TooltipDataType) ~= "table" or Enum.TooltipDataType.Item ~= 0 then return end
|
|
TooltipDataProcessor.AddTooltipPreCall(Enum.TooltipDataType.Item, function(tooltip, data)
|
|
if not pcall(prepare, tooltip, data) then diagnostics.errors = diagnostics.errors + 1 end
|
|
end)
|
|
end)
|