Module:Soreness: Difference between revisions

From Growtopia
Jump to navigationJump to search
>Sorenesss
No edit summary
>Sorenesss
No edit summary
 
(13 intermediate revisions by the same user not shown)
Line 2: Line 2:


function p.test(frame)
function p.test(frame)
    -- Ensure 'class' is initialized as a table
     local class = {}
     local class = {}
     table.insert(class, "growsprite")
     table.insert(class, "growsprite")


    -- Get the input argument
     local newwidth = frame.args[2] or "32"
     local input = tostring(frame.args[1]) or "" -- Default to an empty string if not provided
     local file = frame.args[1] or "Bingo_Card.png"
     local newwidth = frame.args[2] or "32" -- Default to an empty string if not provided
    local imgFilePath = mw.getCurrentFrame():preprocess("{{filepath:"..file.."}}")
local href = input:match('<a%s+[^>]*href="([^"]+)"')
     local baseUrl, queryString = imgFilePath:match("([^?]+)%?(.+)")
    if not href then
     baseUrl = baseUrl:gsub("/revision/latest", "")
        return "Error: Unable to find 'href' in the input."
 
    end
     local imgTag = baseUrl..'/revision/latest/scale-to-width-down/'..newwidth
     local strippedHref = href:match("^(.-)/revision")
     if not strippedHref then
        return "Error: Unable to strip 'href' at '/revision'."
    end
    -- Construct the desired <img> tag
     local imgTag = input..'/revision/latest/scale-to-width-down/scale-to-width-down/'..newwidth
    local imgTagOld = 'https://static.wikia.nocookie.net/growtopia/images/6/6c/'..input..'/revision/latest/scale-to-width-down/'..newwidth


    -- Construct the final output with the growsprite span
     return "<span class='" .. table.concat(class, " ") .. "'>" .. imgTag .. "</span>[[Category:AutoPurge]]"
     return "<span class='" .. table.concat(class, " ") .. "'>" .. imgTag .. "</span>[[Category:AutoPurge]]"
end
end
   
   
return p
return p

Latest revision as of 13:55, 20 November 2024

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

local p = {}

function p.test(frame)
    local class = {}
    table.insert(class, "growsprite")

    local newwidth = frame.args[2] or "32"
    local file = frame.args[1] or "Bingo_Card.png"
    local imgFilePath = mw.getCurrentFrame():preprocess("{{filepath:"..file.."}}")
    local baseUrl, queryString = imgFilePath:match("([^?]+)%?(.+)")
    baseUrl = baseUrl:gsub("/revision/latest", "")

    local imgTag = baseUrl..'/revision/latest/scale-to-width-down/'..newwidth

    return "<span class='" .. table.concat(class, " ") .. "'>" .. imgTag .. "</span>[[Category:AutoPurge]]"
end
 
return p