Module:DropsClue: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:
     -- Define color thresholds and corresponding colors
     -- Define color thresholds and corresponding colors
     local thresholds = {1, 25, 100, 1000, 50000} -- Thresholds
     local thresholds = {1, 25, 100, 1000, 50000} -- Thresholds
     local colors = {"#ff9999", "#7aa7ff", "#d699ff", "#fff59e", "#b3f1ff"} -- Corresponding colors
     local colors = {"#afeeee", "#56e156", "#ffed4c", "#ff863c", "#ff6262"} -- Corresponding colors


     -- Find the appropriate color based on the input number
     -- Find the appropriate color based on the input number

Revision as of 18:15, 7 May 2024

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, 25, 100, 1000, 50000} -- Thresholds
    local colors = {"#afeeee", "#56e156", "#ffed4c", "#ff863c", "#ff6262"} -- 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