Module:Sandbox: Difference between revisions

get all items
get_released_heroes_list
Line 1: Line 1:
local p = {}
local p = {}
local items_data = mw.loadJsonData("Data:ItemData.json")
local items_data = mw.loadJsonData("Data:ItemData.json")
local heroes_data = mw.loadJsonData('Data:HeroData.json')
local heroes_data_release = require('Module:HeroData/release')


function p.get_all_item_names(frame)
function p.get_all_item_names(frame)
Line 17: Line 20:
     -- Merge with commas
     -- Merge with commas
     return table.concat(item_names, ", ")
     return table.concat(item_names, ", ")
end
-- Function to get the list of all released heroes
function p.get_released_heroes_list()
    local released_heroes = {}
   
    for hero_key, hero_data in pairs(heroes_data) do
        if heroes_data_release.get_hero_release_status(hero_key) == "Released" then
            table.insert(released_heroes, hero_data['Name'])
        end
    end
   
    -- Sort hero names alphabetically
    table.sort(released_heroes)
   
    -- Combine into a comma-separated string
    return table.concat(released_heroes, ", ")
end
end


return p
return p