Module:DropsClue

From Roat Pkz
Revision as of 14:37, 21 June 2024 by Hefner (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

local p = {}

-- Define a function to generate output based on the input number
function p.generateOutput(frame)
    local inputNumber = tonumber(frame.args[1]) or 0
    local output = {}

    -- Define color thresholds and corresponding colors
    local thresholds = {1, 2, 26, 100, 1000} -- Thresholds
    local colors = {"#0b5884", "#3c780a", "#a48900", "#b55e0c", "#9f261e"} -- Corresponding colors

    -- Find the appropriate color based on the input number
    local colorIndex = 1
    for i, threshold in ipairs(thresholds) do
        if inputNumber >= threshold then
            colorIndex = i
        else
            break
        end
    end

    -- Add the input number with the appropriate background color
    local color = colors[colorIndex]
    table.insert(output, " style=\"background-color: " .. color .. ";\" | 1/" ..  inputNumber)

    return table.concat(output, '\n')
end

return p