Module:AbilityInteraction: Difference between revisionsGive feedback
Use American spelling in comments per the style guide (with help from vergir-bot LLM) |
make slowing hex be negative (appear with read header), and echo shard - positive (green header) |
||
| (16 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
-- To add an interaction, add a REGISTRY entry: | -- To add an interaction, add a REGISTRY entry: | ||
-- aliases = other names resolving to this entry | -- aliases = other names resolving to this entry | ||
-- title = header text | -- title = header text | ||
-- type = positive | negative | info | -- type = positive | negative | info | ||
-- iconfile = image file name, without the File: prefix | -- iconfile = image file name, without the "File:" prefix | ||
-- link = wiki page name, or a full URL | -- link = wiki page name, or a full URL | ||
local REGISTRY = { | local REGISTRY = { | ||
['ability duration'] = { | |||
aliases = { 'duration', 'duration extender' }, | |||
title = 'Ability Duration', | |||
type = 'positive', | |||
iconfile = 'Duration Extender.png', | |||
link = 'Ability Duration', | |||
}, | |||
['ability range'] = { | |||
aliases = { 'range', 'greater expansion' }, | |||
title = 'Ability Range', | |||
type = 'positive', | |||
iconfile = 'Greater Expansion.png', | |||
link = 'Ability Range', | |||
}, | |||
['cooldown'] = { | |||
aliases = {'ability cooldown', 'superior cooldown' }, | |||
title = 'Ability Cooldown Reduction', | |||
type = 'positive', | |||
iconfile = 'Superior Cooldown.png', | |||
link = 'Ability Cooldown', | |||
}, | |||
['debuff resist'] = { | ['debuff resist'] = { | ||
aliases = { 'debuff reducer' }, | aliases = { 'debuff reducer' }, | ||
| Line 32: | Line 42: | ||
link = 'Dispel Magic', | link = 'Dispel Magic', | ||
}, | }, | ||
[' | ['echo shard'] = { | ||
aliases = {}, | |||
title = 'Echo Shard', | |||
type = 'positive', | |||
iconfile = 'Echo Shard.png', | |||
link = 'Echo Shard', | |||
}, | |||
['heal'] = { | |||
aliases = {'healing', 'healing booster'}, | |||
title = 'Healing', | |||
type = 'positive', | |||
iconfile = 'Healing Booster.png', | |||
link = 'Healing', | |||
}, | |||
['heroic aura'] = { | |||
aliases = {}, | |||
title = 'Heroic Aura', | |||
type = 'positive', | |||
iconfile = 'Heroic Aura.png', | |||
link = 'Heroic Aura', | |||
}, | |||
['indomitable'] = { | |||
aliases = {}, | |||
title = 'Indomitable', | |||
type = 'negative', | |||
iconfile = 'Indomitable.png', | |||
link = 'Indomitable', | |||
}, | |||
['interrupt'] = { | |||
aliases = { 'knockdown', 'stun' }, | |||
title = 'Interrupt', | |||
type = 'negative', | |||
iconfile = 'Knockdown.png', | |||
link = 'Knockdown', | |||
}, | |||
['monster rounds'] = { | |||
aliases = {}, | |||
title = 'Monster Rounds', | |||
type = 'negative', | |||
iconfile = 'Monster Rounds.png', | |||
link = 'Monster Rounds', | |||
}, | |||
['plated armor'] = { | |||
aliases = {}, | |||
title = 'Plated Armor', | |||
type = 'negative', | |||
iconfile = 'Plated Armor.png', | |||
link = 'Plated Armor', | |||
}, | |||
['reactive barrier'] = { | |||
aliases = {}, | aliases = {}, | ||
title = ' | title = 'Reactive Barrier', | ||
type = 'negative', | type = 'negative', | ||
iconfile = ' | iconfile = 'Reactive Barrier.png', | ||
link = ' | link = 'Reactive Barrier', | ||
}, | }, | ||
['slowing hex'] = { | ['slowing hex'] = { | ||
aliases = {}, | aliases = {}, | ||
title = 'Slowing Hex', | title = 'Slowing Hex', | ||
type = ' | type = 'negative', | ||
iconfile = 'Slowing Hex.png', | iconfile = 'Slowing Hex.png', | ||
link = 'Slowing Hex', | link = 'Slowing Hex', | ||
}, | }, | ||
[' | ['stealth'] = { | ||
aliases = {'Veil Walker'}, | |||
title = 'Stealth', | |||
type = 'positive', | |||
iconfile = 'Veil Walker.png', | |||
link = 'Stealth', | |||
}, | |||
['unstoppable'] = { | |||
aliases = {}, | aliases = {}, | ||
title = ' | title = 'Unstoppable', | ||
type = 'negative', | type = 'negative', | ||
iconfile = ' | iconfile = 'Unstoppable.png', | ||
link = ' | link = 'Unstoppable', | ||
}, | }, | ||
} | } | ||
local p = {} | |||
local getArgs = require('Module:Arguments').getArgs | |||
local index = {} | local index = {} | ||
for _, entry in pairs(REGISTRY) do | for _, entry in pairs(REGISTRY) do | ||
for _, alias in ipairs(entry.aliases or {}) do | for _, alias in ipairs(entry.aliases or {}) do | ||
index[alias] = entry | index[mw.ustring.lower(mw.text.trim(alias))] = entry | ||
end | end | ||
end | end | ||
for key, entry in pairs(REGISTRY) do | for key, entry in pairs(REGISTRY) do | ||
index[key] = entry | index[mw.ustring.lower(mw.text.trim(key))] = entry | ||
end | end | ||
| Line 106: | Line 173: | ||
end | end | ||
-- | -- A function to be used on the Template Doc page to list all available Interactions | ||
function p.list(frame) | function p.list(frame) | ||
local keys = {} | local keys = {} | ||
| Line 114: | Line 181: | ||
table.sort(keys) | table.sort(keys) | ||
local out = { '{| class="wikitable"', '! Interaction | local out = { '{| class="wikitable"', '! Interaction !! Example' } | ||
for _, key in ipairs(keys) do | for _, key in ipairs(keys) do | ||
local entry = REGISTRY[key] | local entry = REGISTRY[key] | ||
local | local names = { '<code>' .. key .. '</code>' } | ||
for _, alias in ipairs(entry.aliases or {}) do | for _, alias in ipairs(entry.aliases or {}) do | ||
table.insert( | table.insert(names, '<code>' .. alias .. '</code>') | ||
end | end | ||
table.insert(out, '|-') | table.insert(out, '|-') | ||
table.insert(out, '| | table.insert(out, '| ' .. table.concat(names, ' / ')) | ||
table.insert(out, '| ' .. frame:expandTemplate{ | table.insert(out, '| ' .. frame:expandTemplate{ | ||
title = 'AbilityInteraction', | title = 'AbilityInteraction', | ||