Module:Testing: Difference between revisions

From RuneTails
NES (talk | contribs)
Created page with "local p = {} local categories = { Fish = { 'Bass', 'Bass (Diamond)', 'Bass (Gold)', 'Bass (Jade)', 'Bass (Ruby)' }, Vegetable = { 'Beetroot', 'Carrot', 'Cave Beetroot', 'Cave Carrot', 'Cave Daikon' }, SmallVegetable = { 'Raddish', 'Spring Onion' }, Berry = { 'Abyss Berry', 'Black Berry', 'Bliss Berry', 'Blue Berry', 'Brown Berry' }, Mushroom = { 'Amber Peak', 'Aqua Polka-Dot Delight', 'Azure Whi..."
 
NES (talk | contribs)
Replaced content with "local p = {} function p.getFilename(frame) local url = frame.args[1] or "" return mw.ustring.match(url, ".+/([^/]+)$") or url end return p"
Tag: Replaced
Line 1: Line 1:
local p = {}
local p = {}


local categories = {
function p.getFilename(frame)
    Fish = {
     local url = frame.args[1] or ""
        'Bass', 'Bass (Diamond)', 'Bass (Gold)', 'Bass (Jade)', 'Bass (Ruby)'
     return mw.ustring.match(url, ".+/([^/]+)$") or url
    },
    Vegetable = {
        'Beetroot', 'Carrot', 'Cave Beetroot', 'Cave Carrot', 'Cave Daikon'
    },
    SmallVegetable = {
        'Raddish', 'Spring Onion'
    },
    Berry = {
        'Abyss Berry', 'Black Berry', 'Bliss Berry', 'Blue Berry', 'Brown Berry'
    },
    Mushroom = {
        'Amber Peak', 'Aqua Polka-Dot Delight', 'Azure Whisper', 'Cloudy Pink Puff',
        'Sunset Slimstalk', 'Wizard\'s Starry Hat' -- Original version (with apostrophe)
    },
    Flower = {
        'Daisy'
    },
    Bug = {
        'Bee', 'Caterpillar', 'Cicada', 'Glow Worm', 'Grub', 'Ladybug', 'Pill Bug',
        'Spider', 'Tick', 'Worm'
    }
}
 
-- Function to compare the page name with the Mushroom category
function p.compare_pagename_to_mushroom()
     local pagename = mw.title.getCurrentTitle().text  -- Fetch the current page name dynamically
    local result = "PAGENAME: " .. pagename .. "\n" -- Prepare result string
 
     local matchFound = false  -- Flag to track if a match is found
 
    result = result .. "Checking Mushroom Category Items:\n"
    for _, mushroom in ipairs(categories.Mushroom) do
        if pagename == mushroom then
            matchFound = true
            result = result .. "Match found: " .. mushroom .. "\n"  -- If a match is found, show it
        end
    end
 
    if not matchFound then
        result = result .. "No match found for the page name in the Mushroom category.\n" -- If no match is found, show that
    end
 
    return result  -- Return the result as a string
end
end


return p
return p

Revision as of 02:02, 13 February 2025

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

local p = {}

function p.getFilename(frame)
    local url = frame.args[1] or ""
    return mw.ustring.match(url, ".+/([^/]+)$") or url
end

return p