Module:RiversCuomoSongList

From Weezerpedia

Documentation for this module may be created at Module:RiversCuomoSongList/doc

local p = {}

-- Function to fetch the song name based on RC# from Data:RiversCuomoSongList.tab
function p.getSongName(frame)
    local rcNum = tonumber(frame.args[1])

    -- Fetch the tabular data from the Data namespace
    local songData = mw.ext.data.get("RCSongList.tab")

    -- Initialize the song name to "Song not found" by default
    local songName = "Song not found"

    -- Loop through the data and find the song name for the matching RC#
    for _, row in ipairs(songData.data) do
        local rc = row[1]
        local song = row[2]
        if rc == rcNum then
            songName = song
            break
        end
    end

    return songName
end

return p