Jump to content
Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Link: Difference between revisions

From Teriock
// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Tag: Reverted
Line 1: Line 1:
local p = {}
local p = {}


local namespaces = {
function p.weight ( frame )
    '',
    'Core',
    'Keyword',
    'Category',
    'Condition',
    'Damage',
    'Drain',
    'Property',
    'Ability',
    'Tradecraft',
}
 
local upperCaseNS = {
    'Ability',
    'Class',
}
 
local upperCaseText = {
    'Ethereal',
    'Ethereal Realm',
    'HP',
    'MP',
    'STR',
    'INT',
    'MOV',
    'SNK',
    'PER',
    'SIZE',
    'P',
    'L',
    'M',
    'R',
    'S',
    'W',
    'Material',
    'Material Realm',
    'GM',
    'UB',
    'AP',
    'AV0',
    'AV',
    'BV',
    'AC',
    'DC',
    'ES',
    'Elder Sorcery',
    'OP',
    'Death Bag',
    'BR',
}
 
function contains(tbl, value)
    for _, v in ipairs(tbl) do
        if v == value then
            return true
        end
    end
    return false
end
 
function findNamespace ( title )
    for _, namespace in ipairs(namespaces) do
        local fullTitle = namespace == '' and title or (namespace .. ':' .. title)
        local page = mw.title.new(fullTitle)
        if page and page.exists then
            return namespace
        end
    end
    return ''
end
 
function stripItalics ( text )
    return text:gsub("''", '')
end
 
function p.i ( frame )
    local args = frame.args
    local text = args[1]
    local cleanText = stripItalics(text)
    return frame:preprocess( cleanText )
end
 
function p.l ( frame )
     local args = frame.args
     local args = frame.args
     local title = args[1]
     local size = tonumber(args.size) or 1
     for _, namespace in ipairs(namespaces) do
     local weight = tostring((3 + size)^3) .. ' lb.'
        local fullTitle = namespace == '' and title or (namespace .. ':' .. title)
     return weight
        local page = mw.title.new(fullTitle)
        if page and page.exists then
            if namespace == 'Category' then
                return ' :' .. fullTitle
            else
                return fullTitle
            end
        end
    end
     return title
end
end


function p.m ( frame )
function p.carryingCapacity ( frame )
     local args = frame.args
     local args = frame.args
     local a1 = args['i']
     local size = tonumber(args.size) or 1
     local a2 = args['ii']
     local str = tonumber(args.str) or 0
    local a3 = args['iii']
     if size < 5 then
    if a1 == '0' then
         local carryingCapacity = tostring((60 + (20 * str))) .. ' lb.'
        a1 = nil
    end
    if a2 == '0' then
        a2 = nil
    end
     if a3 == '0' then
         a3 = nil
    end
    local alc = args['lc']
    local auc = args['uc']
    if alc == '0' then
        alc = nil
    end
    if auc == '0' then
        auc = nil
    end
    local ns = ''
    local page = ''
    local text = ''
    local lc = true
    local textPre = ''
    local textPost = ''
    if args['pre'] then
        textPre = args['pre']
    end
    if args['post'] then
        textPost = args['post']
    end
    if a3 then
        ns = a1
        page = stripItalics(a2)
        text = a3
    elseif a2 then
        if contains(namespaces, a1) then
            ns = a1
            page = stripItalics(a2)
            text = a2
        else
            ns = findNamespace(stripItalics(a1))
            page = stripItalics(a1)
            text = a2
        end
    else
        ns = findNamespace(stripItalics(a1))
        page = stripItalics(a1)
        text = a1
    end
    if contains(upperCaseNS, ns) or contains(upperCaseText, text) then
        lc = false
    end
    if auc then
        lc = false
    end
    if alc then
        lc = true
    end
    text = textPre .. text .. textPost
    if lc then
        text = frame:preprocess( string.lower(text) )
    end
    if ns == '' then
        return frame:preprocess( '[[' .. page .. '|' .. text .. ']]' )
     else
     else
         return frame:preprocess( '[[:' .. ns .. ':' .. page .. '|' .. text .. ']]' )
         local carryingCapacity = tostring((60 + (20 * (str + (size - 5)))) ^ 2) .. ' lb.'
    end
end
 
function p.n ( frame )
    local args = frame.args
    local ns = args[1]
    for _, namespace in ipairs(namespaces) do
        if ns == namespace then
            return 'true'
        end
     end
     end
     return ''
     return carryingCapacity
end
end


return p
return p

Revision as of 00:04, 11 February 2025

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

local p = {}

function p.weight ( frame )
    local args = frame.args
    local size = tonumber(args.size) or 1
    local weight = tostring((3 + size)^3) .. ' lb.'
    return weight
end

function p.carryingCapacity ( frame )
    local args = frame.args
    local size = tonumber(args.size) or 1
    local str = tonumber(args.str) or 0
    if size < 5 then
        local carryingCapacity = tostring((60 + (20 * str))) .. ' lb.'
    else
        local carryingCapacity = tostring((60 + (20 * (str + (size - 5)))) ^ 2) .. ' lb.'
    end
    return carryingCapacity
end

return p