Module:Storyline

--[=[

Lua Module for Stroylines Function

--]=]

local p = {}

local util = require("Module:Utility") local collectionData = mw.loadData( 'Module:ItemCollection/data' )

---[==[ local storylineData = mw.loadData( 'Module:Storyline/data' ) --[===[]==] local storylineData = { ["Colors"] = { ["main"] = {nil, "ffc823", "ffff6b", "cc6600"}, ["side"] = {nil, "18e8ca", "36ffbe", "005555"}, ["ttc"] = {true, "450a6c", "930eb9", "dc86ee", "31ac2a"}, },   ["Arrows"] = { ["R"] = "right", ["r"] = "right-", } } --]===]

local function oneCell(tIn, eType, qLink, qTime, qText) local tOut = {}

if storylineData["Arrows"][eType] then tOut = {'">'}		if qLink ~= "" and storylineData["Arrows"][qLink] then			table.insert(tOut, ' [[File:m-arrow-')			table.insert(tOut, storylineData["Arrows"][qLink])			table.insert(tOut, '.png|x35px]]')		end		return table.concat(tOut) .. " "	else		tOut = {' padding: 5px; background: radial-gradient(circle, #', "36d0ff", ' 5%, #', "1ca1fc", ' 100%); border-radius: 15px; font-weight: normal; box-shadow: 0 0 10px #666666; border: ', "none", '; color: #', "3a3a3a", ';">', "", "", "", "", "", "", "", "", "", "", ""} end

if eType == "main" then tOut[10] = "" elseif eType == "side" then tOut[10] = "" else tOut[10] = "" end

if qLink ~= "" then tOut[11] = " '		if qLink:match("^.+ %(%d%)$") then			qLink = qLink:match("(.+) %(%d%)$")		elseif qLink:match("^.+ %(%d%d%)$") then			qLink = qLink:match("(.+) %(%d%d%)$")		end		tOut[16] = qLink		if qLink:match("^.+%#Part %d$") then      			local qName, qAnch = qLink:match("^(.+)%#Part (%d+)$")			tOut[16] = qName .. ", Pt. " .. qAnch 		elseif qLink:match("^.+%#Part %d%d$") then       			local qName, qAnch = qLink:match("^(.+)%#Part (%d+)$")			tOut[16] = qName .. ", Pt. " .. qAnch 		end		tOut[17] = " " end

if storylineData["Colors"][eType] then local eData = storylineData["Colors"][eType]

if eData[3] then tOut[2] = eData[3] end

if eData[2] then tOut[4] = eData[2] end

if eData[5] then tOut[6] = "3.5px solid #" .. eData[5] end

if eData[1] == true then tOut[8] = "f5f3f5" end

if eData[4] and qLink ~= "" then tOut[14] = eData[4] end end

if qTime ~= "" then tOut[18] = " ("		tOut[19] = qTime		tOut[21] = ")" end

if qText ~= "" then table.insert(tOut, ' ') for idx = 4, #tIn do			table.insert(tOut, " - ") table.insert(tOut, tIn[idx]) table.insert(tOut, " ") end table.insert(tOut, ' ') end return table.concat(tOut) .. " " end

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

local tOut = {'\n ', '\n ', '\n ', '\n ', '\n ', '\n ', '\n ', '\n ', '\n '}	local tTh = {'\n '		else			tOut[i] = tTh[i] .. oneCell(tIn, tIn[1], (tIn[2] or ""), (tIn[3] or ""), (tIn[4] or ""))		end	end	return " " .. table.concat(tOut) .. "\n " end

local function findCharacter(collNumb, collNo) local tOut = { ' ',    	' [ Back to Top ]   ', ' \n==', collNumb[1], '==\n \n', ' '		}	local tChar = { " '",		"", -- Character "' \n", "{| style=\"width: 100%;\" class=\"article-table\"\n| width=\"75%\" |\n| align=\"center\" width=\"25%\" |Cp-",		"", -- Character file		".png \n|}\n\n" }	local tGallery = { '")	table.insert(tOut, table.concat(tGallery))	table.insert(tOut,'\n ')

return table.concat(tOut) end

function p.getCharacterStorylines(frame) local collections = {} local storylines = "" local space = ""

for k, v in pairs(collectionData["Collections"]) do   	if k ~= 10 then if k ~= 9999 then table.insert(collections, {k, v}) end end end

table.sort(collections, function(a,b) return a[2][2] < b[2][2] end)

for _, coll in pairs(collections) do       storylines = storylines .. space .. findCharacter(coll[2], coll[1])

space = "\n\n" end

return frame:preprocess(storylines) end

return p