Module:Lore

---	Lore stores details about Risk of Rain 2's logbook entries. --	--	@module		lore --	@alias		p --	@author		User:Paradoxzyx --	@require	Module:Lore/Data --	@release	stable -- local p = {}

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

---	Builds a single logbook lore entry based on in-game presentation. --	@function		p.Lore --	@param			{table} frame Frame object w/ the first argument being the item name --	@return			{string} HTML string of formatted logbook lore entry 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

---	Builds all logbook lore entries based on in-game presentation. --	@function		p.AllLore --	@return			{string} HTML string of formatted logbook lore entries function p.AllLore local all = {} local count = 0 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) count = count + 1 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 "There are " .. count .. " lore entries in the game. \r\n\r\n" .. list end

return p --