Module:Lore

-- local p = {}

local data = require("Module:Lore/Data") local all_lore = data.lore

function p.Lore(frame) local name = frame.args[1] ~= "" and frame.args[1] or mw.title.getCurrentTitle.text local desc = all_lore[name].Desc desc = desc:gsub("^\r?\n", ""):gsub("^%s*(.-)%s*$", "%1"):gsub("", ""):gsub("<\/style>", " "):gsub("(==+)", " %1 "):gsub("(%-%-+)", " %1 "):gsub("\u(%x%x%x%x)", function(s) return mw.ustring.char(tonumber(s, 16)) end) local pre = mw.html.create("pre"):addClass("lore"):wikitext(desc) return pre:done end

function p.AllLore local all = {} for name, lore in pairs(all_lore) do   lore.Name = name if not all[lore.Type] then all[lore.Type] = {} end table.insert(all[lore.Type], lore) end local list = "" for i, v in ipairs({ "Environments", "Items", "Equipment", "Survivors", "Monsters" }) do   table.sort(all[v], function(a, b) return a.Name < b.Name end) list = list .. "==" .. v .. "==\r\n" for i, lore in ipairs(all[v]) do     desc = lore.Desc:gsub("^\r?\n", ""):gsub("^%s*(.-)%s*$", "%1"):gsub("", ""):gsub("<\/style>", " "):gsub("(==+)", " %1 "):gsub("(%-%-+)", " %1 "):gsub("\u(%x%x%x%x)", function(s) return mw.ustring.char(tonumber(s, 16)) end) local pre = mw.html.create("pre"):addClass("lore"):wikitext(desc) list = list .. "" .. lore.Name .. " " .. tostring(pre) .. " \r\n" end end return list end

return p --