FANDOM


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.gallery( frame )
    local name = frame.args[1]
    local str = frame.args[2]
    local spl = split(str, ';')
    local res = ""
    for key, value in pairs(spl) do
        local spl2 = split(value, ':')
        if tablelength(spl2) == 2 then
            res = res .. "\n" .. name .. " " .. trim(spl2[1]) .. ".png | " .. trim(spl2[2])
        end
    end
    return res
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.