Files
lzrdblzzrd fdfc6d391e
Check Localization / Check Localization process (push) Canceled after 0s
fix: always show synergy partner name, strip duplicated lead
2026-09-22 15:00:20 +03:00

84 lines
3.1 KiB
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Personal fork: synergy notes for owned items (Russian).
-- Data comes prebuilt from dead_god_items.json, see
-- EID-localization-audit/build_synergy_table.py and features/eid_synergy_data.lua.
-- When the player owns item A and looks at item B that synergizes with A,
-- the relevant note is appended to B's description.
local MAX_SYNERGY_LINES = 3
local function synergyTableFor(desc)
if EID.SynergyDataRU == nil then return nil end
if desc.ObjType ~= EntityType.ENTITY_PICKUP then return nil end
if desc.ObjVariant == PickupVariant.PICKUP_COLLECTIBLE then
return EID.SynergyDataRU.coll[desc.ObjSubType]
elseif desc.ObjVariant == PickupVariant.PICKUP_TRINKET then
return EID.SynergyDataRU.trink[desc.ObjSubType]
end
return nil
end
local function anyPartnerOwned(entry)
for _, partner in ipairs(entry.partners) do
if EID:PlayersHaveCollectible(partner) then
return true
end
end
return false
end
local function synergyCondition(desc)
if EID:getLanguage() ~= "ru" then return false end
if EID.Config["DisplaySynergies"] == false then return false end
local list = synergyTableFor(desc)
if not list then return false end
for _, entry in ipairs(list) do
if anyPartnerOwned(entry) then
return true
end
end
return false
end
-- Removes leading "«Name»" chunks naming this very partner, so the line
-- does not read "Ladder: «Ladder» / ...". Leads naming other partners stay.
local function stripOwnNameLead(text, name)
local lead = "«" .. name .. "»"
while text:sub(1, #lead) == lead do
text = text:sub(#lead + 1):match("^%s*[/:—,–-]?%s*(.-)%s*$")
end
return text
end
local function synergyCallback(desc)
local list = synergyTableFor(desc)
if not list then return desc end
-- collect (partner, text) pairs for owned partners only
local lines = {}
for _, entry in ipairs(list) do
for _, partner in ipairs(entry.partners) do
if EID:PlayersHaveCollectible(partner) then
lines[#lines + 1] = { partner = partner, text = entry.text }
break
end
end
end
if #lines == 0 then return desc end
-- NOTE: a line starting with "{{Blank}} " gets an invisible bullet (= no dot),
-- and a line containing only "{{Blank}} " renders as an empty paragraph
-- (printBulletPoints advances one lineHeight per #-segment unconditionally)
desc.Description = desc.Description .. "#{{Blank}} #{{Blank}} Синергии:"
for i = 1, math.min(#lines, MAX_SYNERGY_LINES) do
-- NOTE: {{CollectibleID}} renders only the icon; the name is NOT
-- auto-appended by the engine, so prepend the official item name here
local partnerName = EID:getObjectName(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, lines[i].partner)
local body = stripOwnNameLead(lines[i].text, partnerName)
desc.Description = desc.Description .. "#{{Collectible" .. lines[i].partner .. "}} " .. partnerName .. ": " .. body
end
if #lines > MAX_SYNERGY_LINES then
desc.Description = desc.Description .. "#…и ещё синергий: " .. (#lines - MAX_SYNERGY_LINES)
end
return desc
end
EID:addDescriptionModifier("EID Personal Synergy Notes", synergyCondition, synergyCallback)