Module:ActivityList

--[==[-- -- Temporary Lua script to get Activity Lists -- --]==]

local p = {}

local util = require("Module:Utility") local COLL = require("Module:ItemCollection") local ACT = require("Module:Activity-2").main local actData = mw.loadData( 'Module:ActivityList/data' )

function p.getList(frame) local tArgs = util.getArgs(frame)

local GoTo = {["S"] = ""} local tOut = {	'{| class="article-table sortable" style="text-align: center; width: 100%; line-height: 1.5;"\n', '! style="text-align: center; width: 10%;"|Collection\n', '! style="text-align: center; width: 10%;"|Character\n', '! class="unsortable"|Activity\n', '! style="text-align: center; width: 10%;"|+\n', '! style="text-align: center; width: 1%;" class="unsortable"|Time\n', '! style="text-align: center; width: 1', (tArgs[1]=="ANIM" and '0%;"|Location\n' or '%;"|Wished?\n'),			(tArgs[1] and "" or "|- class=\"sorttop\" style=\"border: 3px #3f51b5 dotted;padding: 5px;\"|\n| colspan=\"7\"|Select the duration of the activities you want to see: 60m · 2h · 4h · 6h · 8h · 10h · 12h · 16h · 18h · 24h  "),		}	for item, data in pairs(actData) do		if tArgs[1] and tArgs[1] == "ANIM" and data[9] then			local collname = COLL.getCollection({data[1], "N"})

if not GoTo[collname] then GoTo["S"] = GoTo["S"] .. collname .. "$"               		GoTo[collname] = true end

local tAct = {	'\n|- id="', collname, '"|', '\n| data-sort-value="', COLL.getCollection({data[1], "D"}), '"|', "', COLL.getCollection({data[1], "D"}), "", '\n| id="', data[1], "-", data[5], '"|', data[1], " Level ", data[2], " ", '\n| style="text-align: left;"|', data[5], " ", data[9], " ", '\n|', (data[3]~="" and (" " .. data[3] .. " ''Lvl " .. data[4] .. "'' ") or ""), '\n| data-sort-value="', (data[6]=="60m" and "1h" or data[6]), '"|', data[6], '\n| style="width: 10%;"| ', data[10], ' ', }

table.insert(tOut, table.concat(tAct)) elseif tArgs[1] and data[6] == tArgs[1] then local collname = COLL.getCollection({data[1], "N"})

if not GoTo[collname] then GoTo["S"] = GoTo["S"] .. collname .. "$"               		GoTo[collname] = true end

local tAct = {	'\n|- id="', collname, '"|', '\n| data-sort-value="', COLL.getCollection({data[1], "D"}), '"|', "', COLL.getCollection({data[1], "D"}), "", '\n|', data[1], " Level ", data[2], " ", '\n| style="text-align: left;"|', data[5], '', '\n|', (data[3]~="" and (" " .. data[3] .. " ''Lvl " .. data[4] .. "'' ") or ""), '\n| data-sort-value="', (data[6]=="60m" and "1h" or data[6]), '"|', data[6], '\n|', data[8], }

if data[7] ~= "" then local sep = "" local rOut = "" local requirements = mw.text.split(data[7], "%s*%$%s*") for idx = #requirements, 1, -1 do					local reqname, reqlvl = mw.ustring.match(requirements[idx], "^(.-)%s*#%s*([%d%,]*)$") if not reqname then reqname = requirements[idx] reqlvl = nil end if reqlvl and reqlvl == "" then reqlvl = nil end rOut = " " .. reqname .. "" .. (reqlvl and (" (Ench. Lvl. " .. reqlvl .. ")") or "") .. sep .. rOut if sep == "" then sep = " &" else sep = "," end end tAct[19] = " ''*" .. rOut .. "'' "			end

table.insert(tOut, table.concat(tAct)) elseif not tArgs[1] then local collname = COLL.getCollection({data[1], "N"})

if not GoTo[collname] then GoTo["S"] = GoTo["S"] .. collname .. "$"               		GoTo[collname] = true end

local tAct = {	'\n|- class="mw-collapsible mw-collapsed" id="mw-customcollapsible-', data[6], '"|', "\n|', COLL.getCollection({data[1], "D"}), "", '\n|', data[1], " Level ", data[2], " ", '\n| style="text-align: left;"|', data[5], '', '\n|', (data[3]~="" and (" " .. data[3] .. " ''Lvl " .. data[4] .. "'' ") or ""), '\n| data-sort-value="', (data[6]=="60m" and "1h" or data[6]), '"|', data[6], '\n|', data[8], }

if data[7] ~= "" then local sep = "" local rOut = "" local requirements = mw.text.split(data[7], "%s*%$%s*") for idx = #requirements, 1, -1 do					local reqname, reqlvl = mw.ustring.match(requirements[idx], "^(.-)%s*#%s*([%d%,]*)$") if not reqname then reqname = requirements[idx] reqlvl = nil end if reqlvl and reqlvl == "" then reqlvl = nil end rOut = " " .. reqname .. "" .. (reqlvl and (" (Ench. Lvl. " .. reqlvl .. ")") or "") .. sep .. rOut if sep == "" then sep = " &" else sep = "," end end tAct[16] = " ''*" .. rOut .. "'' "			end

table.insert(tOut, table.concat(tAct)) end end return (tArgs[1] and COLL.getCollection({GoTo["S"], "A"}) or "") .. "\n" .. table.concat(tOut) .. "\n|}" end

return p