Module:AbilityHints: Difference between revisionsGive feedback
Jump to navigation
Jump to search
wording for debuff resist: "duration" => "debuff duration" |
Expand config contract: entries now specify an arbitrary display file and click URL instead of an item; migrate current items to explicit file/link (with help from vergir-bot LLM) |
||
| Line 5: | Line 5: | ||
local AbilityTable = require("Module:AbilityTable") | local AbilityTable = require("Module:AbilityTable") | ||
local ability_data = mw.loadJsonData("Data:AbilityData.json") | local ability_data = mw.loadJsonData("Data:AbilityData.json") | ||
local p = {} | local p = {} | ||
-- Display order. Each entry: { list | -- Display order. Each entry: { list, file, link, tip } | ||
-- | -- list AbilityTable list whose membership shows the icon | ||
-- file image file to display, e.g. "Reactive Barrier.png" | |||
-- link URL opened when the icon is clicked. Use a full/absolute URL: it keeps | |||
-- the anchor title-less, so MediaWiki Page Previews (Popups) ignores it. | |||
-- tip hover tooltip text (may contain simple HTML such as <br> or <b>) | |||
local CONFIG = { | local CONFIG = { | ||
{ list = "melee", | { list = "melee", file = "Melee Lifesteal.png", link = "https://deadlock.wiki/Melee_Lifesteal", tip = "Benefits from melee items" }, | ||
{ list = "movementbased", | { list = "movementbased", file = "Slowing Hex.png", link = "https://deadlock.wiki/Slowing_Hex", tip = "Disabled by Slowing Hex" }, | ||
{ list = "debuffresist", | { list = "debuffresist", file = "Debuff Reducer.png", link = "https://deadlock.wiki/Debuff_Reducer", tip = "Debuff duration reduced by Debuff Resist" }, | ||
{ list = "heal", | { 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", | { list = "reactivebarrier", file = "Reactive Barrier.png", link = "https://deadlock.wiki/Reactive_Barrier", tip = "Triggers Reactive Barrier" }, | ||
{ list = "dispelmagic", | { list = "dispelmagic", file = "Dispel Magic.png", link = "https://deadlock.wiki/Dispel_Magic", tip = "Effect can be dispelled" }, | ||
{ list = "indomitable", | { list = "indomitable", file = "Indomitable.png", link = "https://deadlock.wiki/Indomitable", tip = "Disable prevented by Indomitable" }, | ||
{ list = "unstoppable", | { list = "unstoppable", file = "Unstoppable.png", link = "https://deadlock.wiki/Unstoppable", tip = "Disable prevented by Unstoppable" }, | ||
{ list = "platedarmor", | { list = "platedarmor", file = "Plated Armor.png", link = "https://deadlock.wiki/Plated_Armor", tip = "On-shot effect prevented by Plated Armor" }, | ||
} | } | ||
-- Renders one | -- Renders one icon: a 24px image linking to `link`. A full URL as the link keeps | ||
-- | -- the anchor title-less so Page Previews / Popups ignores it. The wrapper span | ||
local function icon_img( | -- nudges the icon up 2px to match how the card renders inline icons. | ||
local function icon_img(file, link) | |||
return '<span style="position:relative;bottom:2px;">[[File:' .. file .. '|24px|link=' .. link .. ']]</span>' | |||
end | end | ||
-- One full-size hint icon with a tooltip. | -- One full-size hint icon with a tooltip. | ||
local function hint_icon( | local function hint_icon(def) | ||
return '<span class="ability-hint">' .. icon_img( | return '<span class="ability-hint">' .. icon_img(def.file, def.link) | ||
.. '<span class="ability-hint-tip">' .. tip .. '</span></span>' | .. '<span class="ability-hint-tip">' .. def.tip .. '</span></span>' | ||
end | end | ||
| Line 49: | Line 52: | ||
for _, def in ipairs(CONFIG) do | for _, def in ipairs(CONFIG) do | ||
if AbilityTable.is_member(def.list, record, num) then | if AbilityTable.is_member(def.list, record, num) then | ||
table.insert(icons, hint_icon(def | table.insert(icons, hint_icon(def)) | ||
end | end | ||
end | end | ||
Revision as of 23:09, 13 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.
-- Ability interaction hints: small item icons on ability cards showing how an
-- ability interacts with items (dispellable, reduced, blocked, etc.).
-- Membership is decided by Module:AbilityTable.is_member so these icons always
-- agree with the dynamic ability-interaction tables.
local AbilityTable = require("Module:AbilityTable")
local ability_data = mw.loadJsonData("Data:AbilityData.json")
local p = {}
-- Display order. Each entry: { list, file, link, tip }
-- list AbilityTable list whose membership shows the icon
-- file image file to display, e.g. "Reactive Barrier.png"
-- link URL opened when the icon is clicked. Use a full/absolute URL: it keeps
-- the anchor title-less, so MediaWiki Page Previews (Popups) ignores it.
-- tip hover tooltip text (may contain simple HTML such as <br> or <b>)
local CONFIG = {
{ list = "melee", file = "Melee Lifesteal.png", link = "https://deadlock.wiki/Melee_Lifesteal", 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" },
}
-- Renders one icon: a 24px image linking to `link`. A full URL as the link keeps
-- the anchor title-less so Page Previews / Popups ignores it. The wrapper span
-- nudges the icon up 2px to match how the card renders inline icons.
local function icon_img(file, link)
return '<span style="position:relative;bottom:2px;">[[File:' .. file .. '|24px|link=' .. link .. ']]</span>'
end
-- One full-size hint icon with a tooltip.
local function hint_icon(def)
return '<span class="ability-hint">' .. icon_img(def.file, def.link)
.. '<span class="ability-hint-tip">' .. def.tip .. '</span></span>'
end
-- Renders the interaction icon rail for one ability.
-- ability_key the ability's internal key (AbilityCards .Key)
-- ability_num the ability's slot (1-4); coerced to number
-- Returns rail HTML, or '' when the ability has no interactions.
function p.get_icons(ability_key, ability_num)
local record = ability_data[ability_key]
if record == nil then return '' end
local num = tonumber(ability_num)
local icons = {}
for _, def in ipairs(CONFIG) do
if AbilityTable.is_member(def.list, record, num) then
table.insert(icons, hint_icon(def))
end
end
if #icons == 0 then return '' end
return '<div class="ability-section-hints">' .. table.concat(icons) .. '</div>'
end
return p