Editing Module:Patch Formatter

Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 74: Line 74:
     -- Join with commas
     -- Join with commas
     return table.concat(result, ", ")
     return table.concat(result, ", ")
end
-- Function to get all released items with Activation not equal to Passive
function p.get_active_released_items(frame)
    local active_items = {}
   
    for item_key, item_data in pairs(items_data) do
        -- Check if item is released and not passive
        if item_data["Name"] and item_data["IsDisabled"] == false
          and item_data["Activation"] and item_data["Activation"] ~= "Passive" then
            table.insert(active_items, item_data["Name"])
        end
    end
   
    -- Sort alphabetically
    table.sort(active_items)
   
    -- Merge with commas
    return table.concat(active_items, ", ")
end
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
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

Page included on this page: