Module:ItemData/nav: Difference between revisionsGive feedback
Gammaton32 (talk | contribs) m Reverted edit by Gammaton32 (talk) to last revision by Monster Domosed Tag: Rollback |
added generate_active_items_table |
||
| Line 159: | Line 159: | ||
return frame:expandTemplate{title=template_title, args=template_args} | return frame:expandTemplate{title=template_title, args=template_args} | ||
end | |||
-- for [[Template:Active Items]] | |||
function p.generate_active_items_table(frame) | |||
local active_items = {} | |||
-- 1. Collect active items | |||
for item_key, item_data in pairs(items_data) do | |||
if item_data["Name"] and | |||
item_data["IsDisabled"] == false and | |||
item_data["Activation"] and | |||
item_data["Activation"] ~= "Passive" then | |||
table.insert(active_items, { | |||
name = item_data["Name"], | |||
key = item_key, | |||
slot = item_data["Slot"] or "Weapon", | |||
has_active_desc = item_data["ActiveDescription"] ~= nil | |||
}) | |||
end | |||
end | |||
-- 2. Sort by name | |||
table.sort(active_items, function(a, b) return a.name < b.name end) | |||
-- 3. Generate wiki markup | |||
local wikitext = [=[ | |||
{| class="wikitable sortable" style="width:100%" | |||
|+{{#invoke:Dictionary|translate|Active Items}} | |||
! colspan="2" | {{#invoke:Lang|get_string|Citadel_HeroBuilds_CategoryNameLabel}} | |||
! {{#invoke:Lang|get_string|Citadel_UserFeedback_TypeLabel}} | |||
! {{Souls|{{#invoke:Dictionary|translate|Cost}}}} | |||
! {{#invoke:Lang|get_string|Citadel_Mod_Tooltip_Active}} | |||
! {{#invoke:Lang|get_string|AbilityCooldown_label}} | |||
]=] | |||
-- 4. Add rows for each item | |||
for _, item in ipairs(active_items) do | |||
-- Determine background color and item type | |||
local bg_color, item_type | |||
if item.slot == "Armor" then | |||
bg_color = "#86C921" | |||
item_type = "Armor" | |||
elseif item.slot == "Tech" then | |||
bg_color = "#DE9CFF" | |||
item_type = "Tech" | |||
else | |||
bg_color = "#FCAC4D" | |||
item_type = "Weapon" | |||
end | |||
wikitext = wikitext .. "\n" .. string.format([=[ | |||
|- | |||
! style="background-color:%s" | [[File:%s.png|64x64px]] | |||
! [[%s{{If_lang}}|{{#invoke:Lang|get_string|%s}}]] | |||
| style="text-align:center;font-weight:bold" | {{ItemType|%s|{{#invoke:Lang|get_string|CitadelCategory%s}}}} | |||
| style="text-align:center;font-size:15px" | {{Souls|{{#invoke:ItemData|get_cost|%s}}}} | |||
| {{#invoke:Utilities|process_variables|%s_active_desc|%s}}{{#invoke:Utilities|process_variables|%s_desc|%s}}{{#invoke:Utilities|process_variables|%s_active|%s}} | |||
| style="text-align:center;font-size:16px" | {{#invoke:ItemData|get_prop|%s|AbilityCooldown}}s | |||
]=], | |||
bg_color, | |||
item.name, | |||
item.name, item.key, | |||
item_type, item_type, | |||
item.name, | |||
item.key, item.name, item.key, item.name, item.key, item.name, | |||
item.name) | |||
end | |||
wikitext = wikitext .. "\n|}" | |||
return frame:preprocess(wikitext) | |||
end | end | ||
return p | return p | ||