Module:Sandbox/AnataBakka2

-- local p   = {}

local luaskinData = mw.loadData('Module:SkinData/data') local lib      = require('Module:Feature') local json     = require('Module:JSON') local cmd      = require('Module:Maintenance data') local userError = require('Dev:User error') local IL       = require('Module:ImageLink')

function p.get(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local theme  = args[1] or nil local exclude = args[2] or nil local jsonskins = jsontolua("User:AnataBakka/skins") local jsonsets = jsontolua("User:AnataBakka/sets") local jsonuniverses = jsontolua("User:AnataBakka/universes") local setstable={} for _,setdata in pairs(jsonsets) do       setstable[setdata.id]=setdata.name end local universestable={} for _,universedata in pairs(jsonuniverses) do       for _,setid in pairs(universedata.skinSets) do            universestable[setid]=universedata.name end end local championtable = {} local resulttable  = {} for index,skindata in pairs(jsonskins) do       championname=jsonskins[tostring(math.floor(index/1000)*1000)]["name"] if championname ~= exclude and index~=tostring(math.floor(index/1000)*1000) then skinname=skindata["name"] setid=skindata["skinLines"] if setid ~= nil and setid ~= "null" then setid=skindata["skinLines"]["0"]["id"] set=setstable[setid] universe=universestable[setid] if set == theme or universe==theme then if resulttable[championname] == nil then resulttable[championname] = {} table.insert(championtable, championname) end table.insert(resulttable[championname], skinname) end end end end table.sort(championtable) local s = "" for _, championname in pairs(championtable) do       table.sort(resulttable[championname]) for _, skinname in pairs(resulttable[championname]) do           if s == "" then s =     "\n**" .. csl(championname, skinname, frame) else s = s .. "\n**" .. csl(championname, skinname, frame) end end end return s end

function csl(champion, skin, frame) return frame:expandTemplate{ title = "csl", args = {champion, skin} } end

function jsontolua(pagename) local titleobject = mw.title.new(pagename) local o           = json.decode(titleobject:getContent) return o end return p --