Module:ItemData/nav: Difference between revisions

added generate_active_items_table
LVL (talk | contribs)
Fixed sorting for the Souls column in the Active Items table.
Line 165: Line 165:
     local active_items = {}
     local active_items = {}
      
      
     -- 1. Collect active items
     -- 1. Collect active items and their cost
     for item_key, item_data in pairs(items_data) do
     for item_key, item_data in pairs(items_data) do
         if item_data["Name"] and  
         if item_data["Name"] and  
Line 175: Line 175:
                 name = item_data["Name"],
                 name = item_data["Name"],
                 key = item_key,
                 key = item_key,
                cost = tonumber(item_data["Cost"]) or 0,
                 slot = item_data["Slot"] or "Weapon",
                 slot = item_data["Slot"] or "Weapon",
                 has_active_desc = item_data["ActiveDescription"] ~= nil
                 has_active_desc = item_data["ActiveDescription"] ~= nil
Line 210: Line 211:
         end
         end
          
          
        -- The cost cell uses 'data-sort-value' to provide a clean number for the client-side sorter,
        -- while the cell's visible content is formatted by the {{Souls}} template.
         wikitext = wikitext .. "\n" .. string.format([=[
         wikitext = wikitext .. "\n" .. string.format([=[
|-
|-
Line 215: Line 218:
! [[%s{{If_lang}}|{{#invoke:Lang|get_string|%s}}]]
! [[%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-weight:bold" | {{ItemType|%s|{{#invoke:Lang|get_string|CitadelCategory%s}}}}
| style="text-align:center;font-size:15px" | {{Souls|{{#invoke:ItemData|get_cost|%s}}}}
| data-sort-value="%d" style="text-align:center;font-size:15px" | {{Souls|%d}}
| {{#invoke:Utilities|process_variables|%s_active_desc|%s}}{{#invoke:Utilities|process_variables|%s_desc|%s}}{{#invoke:Utilities|process_variables|%s_active|%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
| style="text-align:center;font-size:16px" | {{#invoke:ItemData|get_prop|%s|AbilityCooldown}}s
Line 223: Line 226:
             item.name, item.key,
             item.name, item.key,
             item_type, item_type,
             item_type, item_type,
             item.name,
             item.cost, item.cost,
             item.key, item.name, item.key, item.name, item.key, item.name,
             item.key, item.name, item.key, item.name, item.key, item.name,
             item.name)
             item.name)