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, Game, Faction, Short Story, Video
duration number
description string
previous string
following string | (note: 'next' is a reserved word)
canon string | Legacy, Inspired, Alternate
]]
--[[
Used in
Template:Lore banner getBanner
Template:Lore header getCategories
Template:More lore getMore
Template:Lore feature getFeature
]]
local p = {}
local loreData = mw.loadData('Module:UniverseData/data')
local lib = require('Module:Feature')
local FN = require('Module:Filename')
local builder = require("Module:SimpleHTMLBuilder")
function p.loreTemplate(frame)
local args = lib.frameArguments(frame)
local loretypeArg = args["type"] or "Short Story";
local loreList = ''
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 loretype = t.loretype or "N/A"
local starring = t.starring
local entry = ''
if starring and (args["starring"] == nil or lib.string_to_bool(args["starring"])) then
entry = '* [[' .. piece .. '|' .. piece .. ']] <small>('.. getChampions(starring) ..')</small>\n'
else
entry = '* [[' .. piece .. '|' .. piece .. ']]\n'
end
if loretype == loretypeArg then
loreList = loreList .. entry
end
end
return loreList
end
function p.getLoreTypes()
local loreList = builder.create('ul')
local lore = {}
local res = {}
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 loretype = t.loretype or "N/A"
if not lib.in_array(res, loretype) then
table.insert(res, loretype)
loreList
:tag('li')
:tag('div')
:wikitext(loretype)
:done()
:done()
:newline()
end
end
return loreList
end
function p.getBanner(frame)
local args = lib.frameArguments(frame)
return banner(args["title"], args["footer"] or "true")
end
function p.getFeature(frame)
local args = lib.frameArguments(frame)
return feature(args["title"], args["footer"] or "true")
end
function p.getCategories(frame)
local args = lib.frameArguments(frame)
local s = ""
local t = loreData[args[1]] or loreData["Something Went Wrong"]
local loretype = t.loretype or nil
local starring = t.starring or {}
local mentioned = t.mentioned or {}
local region = t.region or {}
local canon = t.canon or nil
local count = 0
if canon == "Legacy" then
s = s .. "{{Old lore}}[[Category:Runeterra Legacy]]"
end
if canon == "Inspired" then
s = s .. "{{Inspired lore}}"
end
if canon == "Alternate" then
s = s .. "{{Alternate Universe lore}}"
if loretype ~= nil then
if loretype == "Video" then
s = s .. "[[Category:Alternate Universe Video]]"
elseif loretype == "Comic" then
s = s .. "[[Category:Alternate Universe Comic]][[Category:" .. args[1] .. "]]"
elseif loretype == "Game" then
s = s .. "[[Category:Alternate Universe Game]][[Category:" .. args[1] .. "]]"
else
s = s .. "[[Category:Alternate Universe " .. loretype .. "]]"
end
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 ~= nil then
if loretype == "Video" then
s = s .. "[[Category:Video lore]]"
elseif loretype == "Comic" then
s = s .. "[[Category:Comic]][[Category:" .. args[1] .. "]]"
elseif loretype == "Comic" then
s = s .. "[[Category:Lore games]][[Category:" .. args[1] .. "]]"
else
s = s .. "[[Category:" .. loretype .. "]]"
end
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
return frame:preprocess(s)
end
function p.getAuthor(frame)
local args = lib.frameArguments(frame)
return loreData[args[1]].author or {"Unknown Author"}
end
function p.getAuthorlist()
local authors = {}
local hash = {}
local authorList = builder.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()
:newline()
end
return authorList
end
function p.getReference(frame)
local args = lib.frameArguments(frame)
return loreData[args[1]].reference or "https://universe.leagueoflegends.com/en_US/"
end
function p.getArtwork(frame)
local args = lib.frameArguments(frame)
return loreData[args[1]].artwork or "Bard promo 2.jpg"
end
function p.getLorelist(frame)
local loreList = builder.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 = lib.frameArguments(frame)
local champion = args[1]
local article = ""
local bioList = ""
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 ~= "Faction" and t.loretype ~= "Universe" then
for _, substarring in pairs(t.starring) do
if substarring == champion then
hit = true
end
end
end
if hit == true then
if t.canon == nil then
if t.loretype == "Biography" then
bioList = bioList .. banner(piece, "false")
else
loreList = loreList .. banner(piece, "false")
end
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.canon == nil then
mentionedList = mentionedList .. banner(piece, "false")
else
auList = auList .. banner(piece, "false")
end
end
end
if bioList ~= "" then
article = article .. "<h3>Biography</h3>"
article = article .. bioList
end
article = article .. loreList
if mentionedList ~= "" then
article = article .. "\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
article = article .. "\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 article
end
function p.getRegionlore(frame)
local args = lib.frameArguments(frame)
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 = lib.frameArguments(frame)
return loreData[args[1]].description or "Description not specified."
end
function p.getDuration(frame)
local args = lib.frameArguments(frame)
return loreData[args[1]].duration or "Duration not specified."
end
function p.getLoretype(frame)
local args = lib.frameArguments(frame)
return loreData[args[1]].loretype or "Loretype not specified."
end
function p.getMentioned(frame)
local args = lib.frameArguments(frame)
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 = lib.frameArguments(frame)
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 = lib.frameArguments(frame)
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 = lib.frameArguments(frame)
return "{{User:Emptylord/Lore/Banner|" .. args[1] .. "}}"
end
function p.getPrevious(frame)
local args = lib.frameArguments(frame)
return loreData[args[1]].previous or nil
end
function p.getFollowing(frame)
local args = lib.frameArguments(frame)
return loreData[args[1]].following or nil
end
function p.getNarration(frame)
local args = lib.frameArguments(frame)
return loreData[args[1]].narration or nil
end
-- local functions
function banner(name, footer)
local piece = loreData[name] or loreData["Something Went Wrong"]
local s = ""
local ret = builder.create("div")
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.canon 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
if loretype == "Universe" then
link = link .. " (Universe)"
end
local temp = ret
:attr("id", "champinfo-container")
:css("width", "100%")
:css("min-height", "130px")
:css("max-height", "500px")
:css("overflow", "hidden")
:css("position", "relative")
:css("font-size", "14px")
:css("display", "flex")
:css("flex-direction", "column")
:css("z-index", "0")
:tag("div")
:addClass("FillImage")
:css("width", "100%")
:css("height", "100%")
:css("position", "absolute")
:css("top","0")
:css("left", "0")
:css("opacity", "0.3")
:css("z-index", "0")
:wikitext("[[File:" .. artwork .."|link=]]")
:done()
if piece.previous ~= nil then
temp = temp
:tag("div")
:css("position", "absolute")
:css("left", "0")
:css("width", "10%")
:css("height", "100%")
:addClass("universe-banner-nav")
if loreData[piece.previous] ~= nil then
temp = temp
:tag("div")
:addClass("universe-banner-nav-item")
:css("position", "absolute")
:css("left", "0")
:css("width", "200%")
:css("height", "100%")
:css("mask-image", "linear-gradient(to right, rgba(0, 0, 0, 1) 60%, transparent);")
:css("-webkit-mask-image", "linear-gradient(to right, rgba(0, 0, 0, 1) 60%, transparent);")
:tag("div")
:addClass("FullWidth")
:css("position", "absolute")
:css("left", "50%")
:wikitext("[[File:" .. loreData[piece.previous].artwork .. "|x600px|link=" .. piece.previous .. "]]")
:done()
:done()
end
temp = temp
:tag("div")
:css("position","absolute")
:css("top", "50%")
:css("left", "0.4em")
:css("font-size", "3em")
:addClass("basic-tooltip")
:attr("title", piece.previous)
:wikitext("[[" .. piece.previous .. "|⮜]]")
:done()
temp = temp
:done()
end
if piece.following ~= nil then
temp = temp
:tag("div")
:css("position", "absolute")
:css("right", "0")
:css("width", "10%")
:css("height", "100%")
:addClass("universe-banner-nav")
if loreData[piece.following] ~= nil then
temp = temp
:tag("div")
:addClass("universe-banner-nav-item")
:css("position", "absolute")
:css("right", "0")
:css("width", "200%")
:css("height", "100%")
:css("mask-image", "linear-gradient(to left, rgba(0, 0, 0, 1) 60%, transparent);")
:css("-webkit-mask-image", "linear-gradient(to left, rgba(0, 0, 0, 1) 60%, transparent);")
:tag("div")
:addClass("FullWidth")
:css("position", "absolute")
:css("left", "50%")
:wikitext("[[File:" .. loreData[piece.following].artwork .. "|x600px|link=" .. piece.following .. "]]")
:done()
:done()
end
temp = temp
:tag("div")
:css("position","absolute")
:css("top", "50%")
:css("right", "0.4em")
:css("font-size", "3em")
:addClass("basic-tooltip")
:attr("title", piece.following)
:wikitext("[[" .. piece.following .. "|⮞]]")
:done()
temp = temp
:done()
end
temp = temp
:tag("sup")
:css("position", "absolute")
:css("top", "1em")
:css("right", "1em")
:css("z-index", "2")
:tag("span")
:addClass("plainlinks")
:wikitext("[https://leagueoflegends.wikia.com/wiki/Module:UniverseData/data?action=edit Edit]")
:done()
:wikitext(" • [[:File:" .. artwork .."|Image]] • [" .. reference.. " Reference]")
if narfooter == "false" and narration ~= "" then
temp
:wikitext("<br/>[[File:Actor.png|link=File:" .. narration .. "|24px]][[:File:" .. narration .. "|Listen to this article.]]")
end
temp = temp:done()
temp = temp
:tag("div")
:css("text-align", "center")
:css("max-width", "80%")
:css("margin", "auto")
:css("z-index", "1")
:tag("div")
:css("margin", "3em 0")
:tag("p")
:attr("id", "title")
:css("margin", "4em 0 0 0")
:wikitext("[[File:" .. region .. " Crest icon.png|x56px|link=" .. region .."]]")
:done()
if loretype == "Short Story" then
temp = temp:tag("p"):attr("id", "duration"):css("margin","0")
if duration == "0" then
temp = temp:wikitext("Short Story")
else
temp = temp:wikitext("Short Story • " .. duration .." Minute Read")
end
temp = temp:done()
else
temp = temp:tag("p"):attr("id", "duration"):css("margin", "0"):wikitext(loretype):done()
end
temp = temp
:tag("p")
:attr("id", "title")
:css("font-size", "250%")
:css("line-height", "100%")
:css("margin", "0")
:css("color", "#c9aa71")
:wikitext("[[" .. link .. "|" .. bName .."]]")
:done()
if loretype ~= "Video" then
local s = "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
temp = temp
:tag("p")
:attr("id","duration")
:css("margin", "0 0 1em 0")
:wikitext(s)
:done()
end
if loretype ~= "Biography" then
temp = temp
:tag("p")
:attr("id", "blurb")
:css("margin", "1em 0 1em 0")
:css("font-size", "13px")
:css("text-transform", "initial")
:css("line-height", "1.6")
:css("text-shadow", "black 1px 1px")
:wikitext((description:gsub("//n", "<br/>")))
:done()
end
if starring ~= nil then
temp = temp
:tag("p")
:attr("id", "featured")
:css("margin", "0 0 1em 0")
:wikitext("Starring: " .. starring)
:done()
end
if mentioned ~= "N/A" then
temp = temp
:tag("p")
:attr("id", "featured")
:css("margin", "0 0 1em 0")
:wikitext("Mentioned: " .. mentioned)
:done()
end
temp = temp:done()
--/content
temp = temp:done()
if narfooter == "true" and narration ~= "" then
temp = temp:tag("div"):attr("id", "champinfo-container"):css("position", "relative"):css("height", "calc(36px + 2em)"):css("width", "100%"):css("overflow", "hidden"):css("background", "#010a13"):css("text-align", "center"):tag("div"):css("margin-top", "1em")
:wikitext("[[File:Actor.png|36px|link=File:" .. narration .. "]] [[:File:" .. narration .. "|LISTEN TO THIS ARTICLE]]"):done():done()
end
return tostring(ret:allDone())
end
function feature(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.canon 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: 310px; overflow:hidden; position:relative; font-size:14px; color: #dddddd; display:flex;'><div style='margin:0 auto;'>"
--edit
s = s .. "<sup style='position: absolute; top: 1em; right: 1em; z-index:2'><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; max-width: 80%; z-index:1'><div style='margin:3em 0'>"
s = s .. "<p id='title' style='margin:4em 0 0 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:0;'> Short Story </p>"
else
s = s .. "<p id='duration' style='margin:0;'> Short Story • " .. duration .." Minute Read</p>"
end
else
s = s .. "<p id='duration' style='margin:0;'>" .. loretype .. "</p>"
end
if piece.previous ~= nil then
s = s .. "<div style='position: absolute; top: 50%; left:0.4em; font-size:3em;' class='basic-tooltip' title='" .. piece.previous .. "'>[[" .. 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: 0.4em; font-size:3em;' class='basic-tooltip' title='" .. piece.following .. "'>[[" .. 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; text-shadow:black 1px 1px;'>" .. 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
--image
s = s .. "<div class='FillImage fxaa' style='width:25%; position:relative; margin: auto 0;'>[[File:" .. artwork .."|link=]]</div>"
--/image
s = s .. "</div></div>"
--/content
s = s .. "</div></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 .. "Square.png|20px|link=" .. champion .. "]] [[" .. champion .. "|" .. champion .."]]</span>"
end
return s
end
return p
-- </pre>
-- [[Category:Lua]]