Module:AbilityHints: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Move hint icon positioning to a class and add action sentences to hint tooltips (with help from vergir-bot LLM) |
Keep overriding manual hints in their automatic hint's CONFIG-order slot (with help from vergir-bot LLM) |
||
| Line 40: | Line 40: | ||
manual = manual or {} | manual = manual or {} | ||
-- | -- Manual icons indexed by file so an override can take its automatic hint's slot. | ||
local | local manual_by_file = {} | ||
for _, m in ipairs(manual) do | for _, m in ipairs(manual) do | ||
manual_by_file[mw.ustring.lower(m.file)] = m | |||
end | end | ||
local icons = {} | local icons = {} | ||
local placed = {} | |||
-- Automatic hints in CONFIG order; an overriding manual icon takes the slot. | |||
local record = ability_data[ability_key] | local record = ability_data[ability_key] | ||
if record ~= nil then | if record ~= nil then | ||
local num = tonumber(ability_num) | local num = tonumber(ability_num) | ||
for _, def in ipairs(CONFIG) do | for _, def in ipairs(CONFIG) do | ||
if AbilityTable.is_member(def.list, record, num) | if AbilityTable.is_member(def.list, record, num) then | ||
local key = mw.ustring.lower(def.file) | |||
table.insert(icons, hint_icon(def)) | local m = manual_by_file[key] | ||
if m ~= nil then | |||
table.insert(icons, manual_icon(m)) | |||
placed[key] = true | |||
else | |||
table.insert(icons, hint_icon(def)) | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
-- Remaining manual icons (no automatic slot) in their original order. | |||
for _, m in ipairs(manual) do | for _, m in ipairs(manual) do | ||
table.insert(icons, manual_icon(m)) | if not placed[mw.ustring.lower(m.file)] then | ||
table.insert(icons, manual_icon(m)) | |||
end | |||
end | end | ||
Revision as of 22:08, 14 July 2026
Overview
Renders a small strip of item icons showing how an ability interacts with items and used by Module:AbilitySection. Each icon displays a configured image and has a hover tooltip.
Hints can be "automatic" and "manual".
- Automatic come from Module:AbilityTable/Lists. If an ability is part of 'debuffresist' list, then it will show automatic debuff resist hint. List of enabled automatic hints is configured through CONFIG in this module. Clicking on an icon does nothing, however tooltip often will have a link to relevant item/mechanic.
- Manual hints come from
{{AbilityInteraction}}blocks used on AbilitySection. Whenetever an editor describes an interaction using that block a hint will be displayed. Clicking on a hint reveals that hand-written block.
Entry point
p.get_icons(ability_key, ability_num)
Returns the rail HTML for one ability, or an empty string when the ability matches no lists.
Configuration
CONFIG
List of the icons the rail can show. Order within CONFIG does not affect the rendered output — see Display order. Each entry:
| Field | Description |
|---|---|
list |
List name in Module:AbilityTable/Lists whose membership triggers the icon. |
file |
Image file to display, e.g. Reactive Barrier.png. Also determines the icon's position in the rail.
|
tip |
Hover tooltip text. May contain wikilinks and simple HTML (<br>, <b>).
|
To add an icon, add a CONFIG row: pick the triggering list, the display file, and the tip. To re-scope which abilities an icon covers, edit the list in Module:AbilityTable/Lists.
-- Small item icons on ability cards showing how an ability interacts with items (dispellable, reduced, blocked, etc.).
-- Used by Template:AbilitySection. Styles are there too.
local AbilityTable = require("Module:AbilityTable")
local ability_data = mw.loadJsonData("Data:AbilityData.json")
local p = {}
-- Display order. Each entry: { list, file, link, tip }
local CONFIG = {
{ list = "melee", file = "Melee Charge.png", link = "https://deadlock.wiki/Melee_Charge", tip = "Benefits from melee items" },
{ list = "movementbased", file = "Slowing Hex.png", link = "https://deadlock.wiki/Slowing_Hex", tip = "Disabled by Slowing Hex" },
{ list = "debuffresist", file = "Debuff Reducer.png", link = "https://deadlock.wiki/Debuff_Reducer", tip = "Debuff duration reduced by Debuff Resist" },
{ list = "heal", file = "Healing Booster.png", link = "https://deadlock.wiki/Healing_Booster", tip = "Healing amplified by Healing Booster and affected by healing reduction" },
{ list = "reactivebarrier", file = "Reactive Barrier.png", link = "https://deadlock.wiki/Reactive_Barrier", tip = "Triggers Reactive Barrier" },
{ list = "dispelmagic", file = "Dispel Magic.png", link = "https://deadlock.wiki/Dispel_Magic", tip = "Effect can be dispelled" },
{ list = "indomitable", file = "Indomitable.png", link = "https://deadlock.wiki/Indomitable", tip = "Disable prevented by Indomitable" },
{ list = "unstoppable", file = "Unstoppable.png", link = "https://deadlock.wiki/Unstoppable", tip = "Disable prevented by Unstoppable" },
{ list = "platedarmor", file = "Plated Armor.png", link = "https://deadlock.wiki/Plated_Armor", tip = "On-shot effect prevented by Plated Armor" },
{ list = "summons", file = "Monster Rounds.png", link = "https://deadlock.wiki/Monster_Rounds", tip = "Summons affected by Monster Rounds and Heroic Aura" },
}
local function icon_img(file, link)
return '<span class="ability-hint-icon">[[File:' .. file .. '|24px|link=' .. link .. ']]</span>'
end
local function hint_icon(def)
return '<span class="ability-hint">' .. icon_img(def.file, def.link)
.. '<span class="ability-hint-tip">' .. def.tip .. ". Click to go to item's page</span></span>"
end
local function manual_icon(m)
local cls = 'ability-hint'
if m.disabled then cls = cls .. ' ability-hint--disabled' end
return '<span class="' .. cls .. '">' .. icon_img(m.file, '#' .. m.anchor)
.. '<span class="ability-hint-tip">' .. m.title .. ' Interaction. Click to reveal more info</span></span>'
end
function p.get_icons(ability_key, ability_num, manual)
manual = manual or {}
-- Manual icons indexed by file so an override can take its automatic hint's slot.
local manual_by_file = {}
for _, m in ipairs(manual) do
manual_by_file[mw.ustring.lower(m.file)] = m
end
local icons = {}
local placed = {}
-- Automatic hints in CONFIG order; an overriding manual icon takes the slot.
local record = ability_data[ability_key]
if record ~= nil then
local num = tonumber(ability_num)
for _, def in ipairs(CONFIG) do
if AbilityTable.is_member(def.list, record, num) then
local key = mw.ustring.lower(def.file)
local m = manual_by_file[key]
if m ~= nil then
table.insert(icons, manual_icon(m))
placed[key] = true
else
table.insert(icons, hint_icon(def))
end
end
end
end
-- Remaining manual icons (no automatic slot) in their original order.
for _, m in ipairs(manual) do
if not placed[mw.ustring.lower(m.file)] then
table.insert(icons, manual_icon(m))
end
end
if #icons == 0 then return '' end
return '<div class="ability-section-hints">' .. table.concat(icons) .. '</div>'
end
return p