Module:GameFiles

local p = {} local userError = require('Dev:User error') local data = mw.loadData('Module:GameFiles/data') local database = 'https://moomoo.io/img/'

function p.main(frame) local page = mw.title.getCurrentTitle local ns = page.namespace local args = frame:getParent.args local err = userError('file not found', 'Pages with user errors') local lcPage = tostring(page):lower:gsub(' ', '_') local li   local liAll if args['list'] == '3' then li = '*** ' liAll = '*** ' elseif args['list'] == '2' then li = '** ' liAll = '** ' elseif args['list'] == '1' then li = '* ' liAll = '* ' else li = '' liAll = '* ' end local url = li .. database if ns == 6 then local basePage = mw.text.split(lcPage, ':')[2]:gsub('.png', ):gsub('.PNG', ) local splitPage = mw.text.split(basePage, '_') local realSplit1 = splitPage[1] local realSplit2 = splitPage[2] local realSplit3 = splitPage[3] local split1 local split2 local split3 if realSplit1 == 'great' then split1 = realSplit1 .. '_' .. realSplit2 split2 = realSplit3 split3 = splitPage[4] else split1 = realSplit1 split2 = realSplit2 split3 = realSplit3 end local file = data[split1] if realSplit1 == 'duck' or realSplit1 == 'chicken' or realSplit1 == 'bull' then return url .. 'animals/' .. basePage .. '.png' elseif file then local doubleFile = file[split2] if doubleFile then local tripleFile = doubleFile[split3] if tripleFile then return url .. tripleFile .. '.png' else return url .. doubleFile.b .. '.png' end else return file and (type(file) == "table" and "Filename '" .. tostring(page) .. "' has wrong format" or url .. file .. '.png') or err end elseif realSplit1 == 'hat' then return url .. 'hats/' .. basePage .. '.png' elseif realSplit1 == 'access' then return url .. 'accessories/' .. basePage .. '.png' else return url .. basePage .. '.png' end else local real = data.real local file1 = real[lcPage] local file2 = data[lcPage] local ui1 if args[1] then ui1 = args[1]:gsub(' ', '_'):lower end local ui2 if args[2] then ui2 = args[2]:gsub(' ', '_'):lower end if ui1 and ui1 ~= 'b' and ui1 ~= 'g' and ui1 ~= 'd' and ui1 ~= 'r' and ui1 ~= 'e' then if ui1 == 'all' or ui2 == 'all' then local allFile if ui2 then allFile = real[ui1] else allFile = file1 end local orderbase = {'1', 'b', 'g', 'd', 'r', 'e'} local order = {} for k, v in pairs(orderbase) do                   order[v] = k                end local list = {} local templist = {} local temptable = {liAll, nil, nil, '.png\n'} for key, val in pairs(allFile) do                   temptable[2] = database temptable[3] = val templist[order[mw.ustring.sub(val, -1)]] = table.concat(temptable) end for _, val in pairs(templist) do                   table.insert(list, val) end return table.concat(list) else local specialFile1 = real[ui1] local specialFile2 = data[ui1] if specialFile1 then return url .. specialFile1[ui2 or 'b'] .. '.png' elseif specialFile2 then return url .. specialFile2 .. '.png' else return err end end elseif file1 then return url .. file1[ui1 or 'b'] .. '.png' elseif file2 then return url .. file2 .. '.png' else return err end end end

return p