Documentation for this module may be created at Module:UniverseData/doc
-- <pre>
--[[
Key
reference string
author string
artwork string
starring table
mentioned table
region table
loretype string | Biography, Comic, Faction, Short Story, Video
duration number
description string
previous string
following string | (note: 'next' is a reserved word)
au string | if alternative universe stuff set to "True"
status string | if outdated set to "Outdated"
]]
local p = {}
local loreData = mw.loadData('Module:UniverseData/data')
local lib = require('Module:Feature')
local FN = require('Module:Filename')
function p.loreTemplate()
local loreList = mw.html.create('ul')
local lore = {}
for x in pairs(loreData) do
table.insert(lore, x)
end
table.sort(lore)
for _, piece in pairs(lore) do
local t = loreData[piece]
local link = piece
local name = piece
local loretype = t.loretype or "N/A"
local starring = t.starring
local entry = ''
if starring then
entry = '[[' .. link .. '|' .. name .. ']] <small>('.. getChampions(starring) ..')</small>'
else
entry = '[[' .. link .. '|' .. name .. ']]'
end
if loretype == "Short Story" then
loreList
:tag('li')
:tag('div')
:wikitext(entry)
:done()
:done()
:newline()
end
end
return loreList
end
function p.getBanner(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return banner(args["title"], args["footer"] or true)
end
function p.getCategories(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local s = ""
local t = loreData[args[1]] or loreData["Something Went Wrong"]
local loretype = t.loretype or "Missing information"
local starring = t.starring or {}
local mentioned = t.mentioned or {}
local region = t.region or {}
local canon = t.status or {}
local count = 0
if canon == "Outdated" then
s = s .. "[[Category:Old lore]]"
s = s .. "<table style='' class='plainlinks ambox ambox-green'><tr><td class='ambox-image'>[[File:Goodbye, Friend! Emote.png|65px|link=]]</td><td class='ambox-info' style='line-height: 1.5em;'><i>\"Are we done in this reality yet? Hello? Hellooo?\"</i><ul><li> This story is no longer considered to be [[Runeterra Prime|main lore]] canon, but exists here for historical purposes.</li></ul></td></tr></table>"
else
if canon == "Debatable" then
s = s .. "[[Category:Debatable Canon lore]]"
s = s .. "<table style='' class='plainlinks ambox ambox-green'><tr><td class='ambox-image'>[[File:Oops Emote.png|65px|link=]]</td><td class='ambox-info' style='line-height: 1.5em;'><i>\"Paradoxes. I hate those guys.\"</i><ul><li> This story is no longer considered to be [[Runeterra Prime|main lore]] canon, but exists here for reference purposes.</li></ul></td></tr></table>"
end
if t.au == "True" then
s = s .. "<table style='' class='plainlinks ambox ambox-green'><tr><td class='ambox-image'>[[File:Howdy Emote.png|65px|link=]]</td><td class='ambox-info' style='line-height: 1.5em;'><i>\"Frontier's whatever you want it to be.\"</i><ul><li> This story takes place in a [[Multiverse|universe]] other than the [[Runeterra Prime|main one]].</li></ul></td></tr></table>"
if loretype == "Video" then
s = s .. "[[Category:Alternate Universe Video]]"
else
s = s .. "[[Category:Alternate Universe " .. loretype .. "]]"
end
if loretype == "Comic" then
s = s .. "[[Category:" .. args[1] .. "]]"
end
else
if region ~= nil then
for i, region in pairs(region) do
s = s .. "[[Category:Lore of " .. region .. "]]"
end
else
s = s .. "[[Category: Lore with no regional setting]]"
end
if loretype == "Video" then
s = s .. "[[Category:Video lore]]"
else
s = s .. "[[Category:" .. loretype .. "]]"
end
if loretype == "Comic" then
s = s .. "[[Category:" .. args[1] .. "]]"
end
end
for i, champion in pairs(starring) do
s = s .. "[[Category:" .. champion .. " lore]]"
count = count + 1
end
for i, champion in pairs(mentioned) do
s = s .. "[[Category:" .. champion .. " lore]]"
end
if count == 0 then
s = s .. "[[Category: Lore with no starring champion]]"
end
end
return s
end
function p.getAuthor(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return loreData[args[1]].author or {"Unknown Author"}
end
function p.getAuthorlist()
local authors = {}
local hash = {}
local authorList = mw.html.create('ul')
authorList:newline()
for _, x in pairs(loreData) do
if x.author ~= nil then
for _, value in pairs(x.author) do
if (not hash[value]) then
table.insert(authors, value)
hash[value] = true
end
end
end
end
table.sort(authors)
for _, author in pairs(authors) do
authorList
:tag('li')
:wikitext('[[' .. author .. ']]')
:done()
:done()
:newline()
end
return authorList
end
function p.getReference(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return loreData[args[1]].reference or "https://universe.leagueoflegends.com/en_US/"
end
function p.getArtwork(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return loreData[args[1]].artwork or "Bard promo 2.jpg"
end
function p.getLorelist(frame)
local loreList = mw.html.create('ul')
local lore = {}
for x in pairs(loreData) do
table.insert(lore, x)
end
table.sort(lore)
for _, piece in pairs(lore) do
local t = loreData[piece]
local link = piece
local name = piece
local loretype = t.loretype or "N/A"
if loretype == "Biography" then
link = t.starring[1]
end
loreList
:tag('li')
:tag('div')
:wikitext('[[' .. link .. '|' .. name .. ']] ('.. loretype ..')')
:done()
:done()
:newline()
end
return loreList
end
function p.getMore(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local champion = args[1]
local loreList = ""
local mentionedList = ""
local auList = ""
local lore = {}
for x in pairs(loreData) do
table.insert(lore, x)
end
table.sort(lore)
loreList = loreList .. "<h3>Starring Champion</h3>"
for _, piece in pairs(lore) do
local hit = false
local t = loreData[piece]
if t.starring ~= nil and t.loretype ~= "Biography" and t.loretype ~= "Faction" and t.status ~= "Outdated" then
for _, substarring in pairs(t.starring) do
if substarring == champion then
hit = true
end
end
end
if hit == true then
if t.au ~= "True" then
loreList = loreList .. banner(piece,false)
else
auList = auList .. banner(piece,false)
end
end
end
for _, piece in pairs(lore) do
local hit = false
local t = loreData[piece]
if t.mentioned ~= nil then
for _, submentioned in pairs(t.mentioned) do
if submentioned == champion then
hit = true
end
end
end
if hit == true then
if t.au ~= "True" then
mentionedList = mentionedList .. banner(piece,false)
else
auList = auList .. banner(piece,false)
end
end
end
if mentionedList ~= "" then
loreList = loreList .. "\n<div class='va-collapsible-content mw-collapsible mw-collapsed' data-expandtext='show' data-collapsetext='hide'><h3>Mentioned Champion</h3><div class='va-collapsible-content mw-collapsible-content'>" .. mentionedList .. "</div></div>"
end
if auList ~= "" then
loreList = loreList .. "\n<div class='va-collapsible-content mw-collapsible mw-collapsed' data-expandtext='show' data-collapsetext='hide'><h3>Alternate Universes</h3><div class='va-collapsible-content mw-collapsible-content'>" .. auList .. "</div></div>"
end
return loreList
end
function p.getRegionlore(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
local loreList = ""
local lore = {}
local result = false
for x in pairs(loreData) do
table.insert(lore, x)
end
table.sort(lore)
for _, piece in pairs(lore) do
local hit = false
local t = loreData[piece]
if (t.region ~= nil) then
for _, subregion in pairs(t.region) do
if subregion == args[1] then
hit = true
result = true
end
end
else
if args[1] == "Runeterra" then
hit = true
result = true
end
end
if hit == true then
loreList = loreList .. banner(piece,false)
end
end
if result == false then
loreList = "No match found for " .. args[1] .. "."
end
return loreList .. "[[Category:Test]]"
end
function p.getDescription(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return loreData[args[1]].description or "Description not specified."
end
function p.getDuration(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return loreData[args[1]].duration or "Duration not specified."
end
function p.getLoretype(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return loreData[args[1]].loretype or "Loretype not specified."
end
function p.getMentioned(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
if loreData[args[1]].mentioned == nil then
return "N/A"
else
return getChampions(loreData[args[1]].mentioned)
end
end
function p.getRegion(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
if loreData[args[1]].region == nil then
return "Runeterra"
else
return lib.tbl(loreData[args[1]].region)
end
end
function p.getStarring(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
if loreData[args[1]].starring == nil then
return "N/A"
else
return getChampions(loreData[args[1]].starring)
end
end
function p.getTest(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return "{{User:Emptylord/Lore/Banner|" .. args[1] .. "}}"
end
function p.getPrevious(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return loreData[args[1]].previous or nil
end
function p.getFollowing(frame)
local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
return loreData[args[1]].following or nil
end
-- local functions
function banner(name, footer)
local piece = loreData[name] or loreData["Something Went Wrong"]
local s = ""
local bName = piece.altname or name
local artwork = piece.artwork or "Bard promo 2.jpg"
local author = piece.author or {"Unknown Author"}
local reference = piece.reference or "https://universe.leagueoflegends.com/en_US/"
local link = name
local region = "Runeterra"
local duration = piece.duration or "0"
local starring = "N/A"
local mentioned = "N/A"
local canon = piece.status or ""
local loretype = piece.loretype or ""
local description = piece.description or ""
local narration = piece.narration or ""
local narfooter = footer or false
if loretype == "Biography" then link = piece.starring[1] end
if piece.region ~= nil then region = piece.region[1] end
if piece.starring ~= nil then starring = getChampions(piece.starring) end
if piece.mentioned ~= nil then mentioned = getChampions(piece.mentioned) end
s = s .. "<div id='champinfo-container' style='width:100%; min-height: 290px; overflow:hidden; position:relative; font-size:14px; color: #dddddd; display:flex;'>"
--image
s = s .. "<div class='FillImage' style='width:100%; height:100%; position:absolute; top: 0; left:0; opacity:0.2; z-index: -1;'>[[File:" .. artwork .."|link=]]</div>"
--/image
--edit
s = s .. "<sup style='position: absolute; top: 1em; right: 1em;'><span class='plainlinks'>[https://leagueoflegends.wikia.com/wiki/Module:UniverseData/data?action=edit Edit]</span> • [[:File:" .. artwork .."|Image]] • [" .. reference.. " Reference]"
if narfooter == false and narration ~= "" then
s = s .. "<br/>[[File:Actor.png|link=File:" .. narration .. "|24px]][[:File:" .. narration .. "|Listen to this article.]]"
end
s = s .. "</sup>"
--/edit
--content
s = s .. "<div style='text-align:center; width: 500px; margin:auto;'><div style='margin:3em 0'>"
s = s .. "<p id='title' style='margin:1em 0 1em 0;'>[[File:" .. region .. " Crest icon.png|x56px|link=" .. region .."]]</p>"
if loretype == "Short Story" then
if duration == "0" then
s = s .. "<p id='duration' style='margin:1em 0 0 0;'> Short Story </p>"
else
s = s .. "<p id='duration' style='margin:1em 0 0 0;'> Short Story • " .. duration .." Minute Read</p>"
end
else
s = s .. "<p id='duration' style='margin:1em 0 0 0;'>" .. loretype .. "</p>"
end
if piece.previous ~= nil then
s = s .. "<div style='position: absolute; top: 50%; left:1em; font-size:3em;'>[[" .. piece.previous .. "|⮜]]</div>"
end
s = s .. "<p id='title' style='font-size:250%; line-height:100%; margin:0;color:#c9aa71;'>[[" .. link .. "|" .. bName .."]]</p>"
if loretype ~= "Video" then
s = s .. "<p id='duration' style='margin:0 0 1em 0;'> By "
for i, value in ipairs(author) do
if i ~= 1 then
s = s .. ", "
end
if value == "Unknown Author" or value == "Numerous creators" then
s = s .. value
else
s = s .. "[[" .. value .. "]]"
end
end
s = s .. "</p>"
end
if piece.following ~= nil then
s = s .. "<div style='position: absolute; top: 50%; right: 1em; font-size:3em;'>[[" .. piece.following .. "|⮞]]</div>"
end
if loretype ~= "Biography" then
s = s .. "<p id='blurb' style='margin:1em 0 1em 0; font-size: 89%; text-transform: initial;'>" .. description:gsub("//n", "<br/>") .."</p>"
end
if starring ~= nil and loretype ~= "Biography" then
s = s .. "<p id='featured' style='margin:0 0 1em 0;'>Starring: " .. starring .. "</p>"
end
if mentioned ~= "N/A" then
s = s .. "<p id='featured' style='margin:0 0 1em 0;'>Mentioned: " .. mentioned .. "</p>"
end
s = s .. "</div></div>"
--/content
s = s .. "</div>"
if narfooter == true and narration ~= "" then
s = s .. "<div id='champinfo-container' style='position:relative; height:calc(36px + 2em); width: 100%; overflow:hidden; background:#010a13; text-align:center;'><div style='margin-top:1em;'>[[File:Actor.png|36px|link=File:" .. narration .. "]] [[:File:" .. narration .. "|LISTEN TO THIS ARTICLE]]</div></div>"
end
return s
end
function getChampions(t)
local s = ""
local championtable = {}
for i, champion in pairs(t) do
table.insert(championtable, champion)
end
table.sort(championtable)
for i, champion in pairs(championtable) do
if i ~= 1 then
s = s .. ", "
end
s = s .. "<span style='white-space:nowrap'>[[File:" .. champion .. " OriginalSquare.png|20px|link=" .. champion .. "]] [[" .. champion .. "]]</span>"
end
return s
end
return p
-- </pre>
-- [[Category:Lua]]