Module:StatusEffect

---	StatusEffect contains details of Risk of Rain 2's status effects. --	--	@module		statuseffect --	@alias		p --	@author		User:Thundermaker300 --	@attribution	All who helped to update status effect templates --	@require	Module:StatusEffect/Data --	@release	stable --

local StatusData = mw.loadData('Module:StatusEffect/Data').StatusEffects

local p = {}

function pairsByKeys (t, f) -- Sort tables, copied from https://www.lua.org/pil/19.3.html local a = {} for n in pairs(t) do table.insert(a, n) end table.sort(a, f) local i = 0      -- iterator variable local iter = function   -- iterator function i = i + 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end return iter end

function getData(unfriendlyName) for _, entry in pairs(StatusData) do		if entry.InternalName == unfriendlyName then return entry end end return nil end

---	Builds a template for a status effect's expansion. --	@function		p.StatusExpansion --	@param			{table} frame Frame object --	@return			{string} Preprocessed wikitext of expansion template. function p.StatusExpansion(frame) local data = StatusData[frame.args[1]] or getData(frame.args[1]) if data == nil then return "" end return data.Expansion and frame:preprocess("") or "" end

function p.TypeCount(frame) local c = 0 for _, entry in pairs(StatusData) do		if entry.Type == frame.args[1] or frame.args[1]:lower == "all" then c = c + 1 end end return c end

return p