Module:Soreness: Difference between revisions

From Growtopia
Jump to navigationJump to search
>Sorenesss
No edit summary
>Sorenesss
No edit summary
Line 7: Line 7:


     -- Get the input argument
     -- Get the input argument
     local input = frame.args[1] or ""
     local input = tostring(frame[1])
   
     local newwidth = tostring(frame[2])
    -- Extract the <img> tag's src attribute
     local src = input:match('<img[^>]-src="([^"]+)"')
    if not src then
        return "Error: Unable to find 'src' in the input."..tostring(input)
    end


     -- Construct the desired <img> tag
     -- Construct the desired <img> tag
     local imgTag = '<img src="' .. src .. '" alt="Generated Image">'
     local imgTag = '<img src="https://static.wikia.nocookie.net/growtopia/images/6/6c/'..input..'/revision/latest/scale-to-width-down/'..newwidth..'" alt="Generated Image">'


     -- Construct the final output with the growsprite span
     -- Construct the final output with the growsprite span

Revision as of 12:16, 20 November 2024

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

local p = {}

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

    -- Get the input argument
    local input = tostring(frame[1])
    local newwidth = tostring(frame[2])

    -- Construct the desired <img> tag
    local imgTag = '<img src="https://static.wikia.nocookie.net/growtopia/images/6/6c/'..input..'/revision/latest/scale-to-width-down/'..newwidth..'" alt="Generated Image">'

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