Module:Icon: Difference between revisions

LVL (talk | contribs)
Switch to pre-built lookup table for faster page rendering
LVL (talk | contribs)
Fixed "Icon not found" errors for unused items by adding legacyItems fallback logic and image overrides for Bullet/Spirit Armor.
Line 9: Line 9:
     ["Bullet Lifesteal"] = "Bullet Lifesteal (item)",
     ["Bullet Lifesteal"] = "Bullet Lifesteal (item)",
     ["Spirit Lifesteal"] = "Spirit Lifesteal (item)"
     ["Spirit Lifesteal"] = "Spirit Lifesteal (item)"
}
local legacyItems = {
    ["ammo scavenger"] = { name = "Ammo Scavenger", type = "item" },
    ["enduring spirit"] = { name = "Enduring Spirit", type = "item" },
    ["bullet armor"]    = { name = "Bullet Armor", type = "item" },
    ["spirit armor"]    = { name = "Spirit Armor", type = "item" },
    ["soul explosion"]  = { name = "Soul Explosion", type = "item" },
    ["soul rebirth"]    = { name = "Soul Rebirth", type = "item" },
}
}


Line 20: Line 29:
     ["swan"] = "Module-Icon missing.png",
     ["swan"] = "Module-Icon missing.png",
     ["thumper"] = "Module-Icon missing.png",
     ["thumper"] = "Module-Icon missing.png",
    ["bullet armor"] = "Bullet Armor (item).png",
    ["spirit armor"] = "Spirit Armor (item).png",
}
}


Line 84: Line 95:
     end
     end


    -- 1. Check live game data
     local iconInfo = iconData[lowerName]
     local iconInfo = iconData[lowerName]
   
    -- 2. If not found, check legacy/unused items
    if not iconInfo then
        iconInfo = legacyItems[lowerName]
    end


    -- 3. If still not found, throw error
     if not iconInfo then
     if not iconInfo then
         return string.format("[[:Category:Module:Icon ERROR|Icon not found]] ('%s'). [[Category:Module:Icon ERROR]]", name)
         return string.format("[[:Category:Module:Icon ERROR|Icon not found]] ('%s'). [[Category:Module:Icon ERROR]]", name)