FANDOM


-- <nowiki>
local p = {}
 
-- http://lua-users.org/wiki/StringTrim
function trim(s)
    return (s:gsub("^%s*(.-)%s*$", "%1"))
end
 
-- http://stackoverflow.com/questions/1426954/split-string-in-lua
function split(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end
 
-- http://stackoverflow.com/questions/2705793/how-to-get-number-of-entries-in-a-lua-table
function tablelength(table)
    local count = 0
    for _ in pairs(table) do
        count = count + 1
    end
    return count
end
 
function p.filetype(frame)
    local str = frame.args[1]
    local spl = split(str, ',')
    local res = ''
    for key, value in pairs(spl) do
        res = res .. '{{Fileinfo/type|' .. trim(value) .. '}}<br />'
    end
    return frame:preprocess(res:sub(0, -7))
end
 
function p.items(frame)
    local str = frame.args[1]
    if str == '-' then
        return 'N/A'
    end
    local spl = split(str, ',')
    local res = ''
    for key, value in pairs(spl) do
        res = res .. '[[File:' .. trim(value) .. '.png]]'
    end
    return frame:preprocess(res)
end
 
function p.item_name(frame)
    local str = trim(frame.args[1])
    if str:sub(0, 1) == '+' then
        return frame:preprocess('<span style="color: #80FF80">' .. str:sub(2) .. '</span>')
    end
    return str
end
 
function p.item_id(frame)
    local subd, _ = frame.args[1]:lower():gsub('[\'\(\)\?"]', '')
    subd, _ = trim(subd):gsub('  ', ' ')
    subd, _ = trim(subd):gsub(' ', '_')
    return subd
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.