Module:AbilitySection: Difference between revisions

Jump to navigation Jump to search
Detect interaction state (disabled/partial) and pass it to the hint rail (with help from vergir-bot LLM)
Vergir (talk | contribs)
Identify interaction boxes by their data attributes rather than CSS class names, so box styling can change independently (with help from vergir-bot LLM)
Line 29: Line 29:
local function process_interactions(html, ability_num)
local function process_interactions(html, ability_num)
local manual, idx, seen = {}, 0, {}
local manual, idx, seen = {}, 0, {}
local out = html:gsub('(<div class="ai%-box)([^>]*)(>)', function(pre, attrs, post)
-- Boxes are identified by their data-ai-* attributes, which are the contract
-- with Template:IconBox. Class names are presentational and deliberately not
-- matched here, so box styling can change without touching this.
local out = html:gsub('(<div)([^>]*data%-ai%-icon="[^"]*"[^>]*)(>)', function(pre, attrs, post)
local file = attrs:match('data%-ai%-icon="([^"]*)"')
local file = attrs:match('data%-ai%-icon="([^"]*)"')
if file and file ~= '' then
if file and file ~= '' then
Line 38: Line 41:
idx = idx + 1
idx = idx + 1
local box_id = 'ai-int-' .. ability_num .. '-' .. idx
local box_id = 'ai-int-' .. ability_num .. '-' .. idx
local state = 'normal'
if attrs:find('ai%-disabled') then
state = 'disabled'
elseif attrs:find('ai%-partial') then
state = 'partial'
end
table.insert(manual, {
table.insert(manual, {
file  = file,
file  = file,
title  = attrs:match('data%-ai%-title="([^"]*)"') or '',
title  = attrs:match('data%-ai%-title="([^"]*)"') or '',
state  = state,
state  = attrs:match('data%-ai%-state="([^"]*)"') or 'normal',
anchor = box_id,
anchor = box_id,
})
})