Module:GameInputs: Difference between revisions

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Jump to navigation Jump to search
Content deleted Content added
No edit summary
Tag: Reverted
mNo edit summary
 
(6 intermediate revisions by one other user not shown)
Line 14: Line 14:
ptnultimate = '<span style="background-color:#a12932; color:white; font-size:12px; padding:3px 5px; font-family:Roboto Slab;">Ultimate</span>',
ptnultimate = '<span style="background-color:#a12932; color:white; font-size:12px; padding:3px 5px; font-family:Roboto Slab;">Ultimate</span>',
ptnpassive = '<span style="background-color:#4e699e; color:white; font-size:12px; padding:3px 5px; font-family:Roboto Slab;">Passive</span>',
ptnpassive = '<span style="background-color:#4e699e; color:white; font-size:12px; padding:3px 5px; font-family:Roboto Slab;">Passive</span>',
ptnenergy = '<span style="background-color:#552a58; color:white; font-size:12px; border-radius:5px; padding:3px 5px; font-family:Roboto Slab;">' ..
ptnenergy = '<span style="background-color:#552a58; color:white; font-size:12px; border-radius:5px; padding:3px 5px; font-family:Roboto Slab;">' .. '%sCost %s</span>',
'<img src="%s" alt="Energy Icon" style="height:12px; vertical-align:middle; margin-right:3px;">Cost %s</span>',
ptncore = '<span style="background-color:#624a1e; color:white; font-size:12px; border-radius:5px; padding:3px 5px; font-family:Roboto Slab;">' .. '%sCore Dmg %s</span>'
ptncore = '<span style="background-color:#624a1e; color:white; font-size:12px; border-radius:5px; padding:3px 5px; font-family:Roboto Slab;">' ..
'<img src="%s" alt="Core Icon" style="height:12px; vertical-align:middle; margin-right:3px;">Core Dmg %s</span>',
}
}


-- Function to get the full URL for a local file
-- Function to generate a `[[File:...]]` tag for the given file
local function getFileUrl(fileName)
local function getFileTag(fileName, size)
local title = mw.title.new(fileName, "File")
size = size or "20"
return mw.text.tag("span", {
if title and title.exists then
return title:getUrl()
["class"] = "image",
["style"] = "display:inline-block; vertical-align:middle; margin-right:3px;",
else
}, '[[File:' .. fileName .. '|' .. size .. 'px|link=|alt=]]')
return "" -- Return an empty string if the file does not exist
end
end
end


Line 35: Line 31:
local output = {}
local output = {}
-- Get URLs for the local images
-- Generate the file tags for local images
local energyIcon = getFileUrl("PtN Energy Icon.png")
local energyIcon = getFileTag("PtN Energy Icon.png")
local coreIcon = getFileUrl("PtN Core Icon.png")
local coreIcon = getFileTag("PtN Core Icon.png")


-- Loop through user inputs
-- Loop through user inputs
Line 47: Line 43:
local number = args[i + 1] or ""
local number = args[i + 1] or ""
table.insert(output, inputStyles[value]:format(coreIcon, number))
table.insert(output, inputStyles[value]:format(coreIcon, number))
elseif inputStyles[value] then
-- Handle inputs without numbers
table.insert(output, inputStyles[value])
end
end
end
end

Latest revision as of 16:24, 21 February 2025

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

local p = {}

local inputStyles = {
    normal = '<span style="border:1px solid #b566ff; color:#b566ff; font-size:12px; border-radius:5px; padding:1px 5px; font-family:Roboto Slab;">NORMAL</span>',
    stand = '<span style="border:1px solid #91b704; color:#91b704; font-size:12px; border-radius:5px; padding:1px 5px; font-family:Roboto Slab;">STAND</span>',
    chargeable = '<span style="border:1px solid #8d7cff; color:#8d7cff; font-size:12px; border-radius:5px; padding:1px 5px; font-family:Roboto Slab;">CHARGEABLE</span>',
    ["on ground"] = '<span style="border:1px solid #ff9966; color:#ff9966; font-size:12px; border-radius:5px; padding:1px 5px; font-family:Roboto Slab;">ON GROUND</span>',
    ["when downed"] = '<span style="border:1px solid #EA5AE8; color:#EA5AE8; font-size:12px; border-radius:5px; padding:1px 5px; font-family:Roboto Slab;">WHEN DOWNED</span>',
    ["in air ok"] = '<span style="border:1px solid #64bbd5; color:#64bbd5; font-size:12px; border-radius:5px; padding:1px 5px; font-family:Roboto Slab;">IN AIR OK</span>',
    ["ex skill"] = '<span style="border:1px solid #af4748; color:#af4748; font-size:12px; border-radius:5px; padding:1px 5px; font-family:Roboto Slab;">EX SKILL</span>',
    trap = '<span style="border:1px solid #c378ed; color:#c378ed; font-size:12px; border-radius:5px; padding:1px 5px; font-family:Roboto Slab;">TRAP</span>',
    ["switch mode"] = '<span style="border:1px solid #b9691e; color:#b9691e; font-size:12px; border-radius:5px; padding:1px 5px; font-family:Roboto Slab;">SWITCH MODE</span>',
    ptnnormal = '<span style="background-color:#898d96; color:white; font-size:12px; padding:3px 5px; font-family:Roboto Slab;">Normal ATK</span>',
    ptnultimate = '<span style="background-color:#a12932; color:white; font-size:12px; padding:3px 5px; font-family:Roboto Slab;">Ultimate</span>',
    ptnpassive = '<span style="background-color:#4e699e; color:white; font-size:12px; padding:3px 5px; font-family:Roboto Slab;">Passive</span>',
    ptnenergy = '<span style="background-color:#552a58; color:white; font-size:12px; border-radius:5px; padding:3px 5px; font-family:Roboto Slab;">' .. '%sCost %s</span>',
    ptncore = '<span style="background-color:#624a1e; color:white; font-size:12px; border-radius:5px; padding:3px 5px; font-family:Roboto Slab;">' .. '%sCore Dmg %s</span>'
}

-- Function to generate a `[[File:...]]` tag for the given file
local function getFileTag(fileName, size)
    size = size or "20"
    return mw.text.tag("span", {
        ["class"] = "image",
        ["style"] = "display:inline-block; vertical-align:middle; margin-right:3px;",
    }, '[[File:' .. fileName .. '|' .. size .. 'px|link=|alt=]]')
end

function p.renderInputs(frame)
    local args = frame.args
    local output = {}
    
    -- Generate the file tags for local images
    local energyIcon = getFileTag("PtN Energy Icon.png")
    local coreIcon = getFileTag("PtN Core Icon.png")

    -- Loop through user inputs
    for i, value in ipairs(args) do
        if value == "ptnenergy" and inputStyles[value] then
            local number = args[i + 1] or ""
            table.insert(output, inputStyles[value]:format(energyIcon, number))
        elseif value == "ptncore" and inputStyles[value] then
            local number = args[i + 1] or ""
            table.insert(output, inputStyles[value]:format(coreIcon, number))
        elseif inputStyles[value] then
            -- Handle inputs without numbers
            table.insert(output, inputStyles[value])
        end
    end

    return table.concat(output, " ")
end

return p