Module:HeroData/headcount: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
m hero lab heroes no longer include released heroes
Sur (talk | contribs)
m minor typo in error msg
 
Line 17: Line 17:
end
end
else
else
return "get_headcount()'s hero_type parameter must be either 'Released' or 'HeroLabs"
return "get_headcount()'s hero_type parameter must be either 'Released' or 'HeroLabs'"
end
end
end
end

Latest revision as of 02:19, 25 October 2024

Documentation for this module may be created at Module:HeroData/headcount/doc

local p = {}
local heroes_data = mw.loadJsonData("Data:HeroData.json")

-- {{Heroes count}} access point
function p.get_headcount(frame)
	local hero_type = frame.args[1]
	
	local iter = 0
	for _, v in pairs(heroes_data) do
		if hero_type == 'Released' then
			if (v["InDevelopment"] == false and v["IsDisabled"] == false and v["Name"] ~= nil) then
				iter = iter + 1	
			end
		elseif hero_type == 'HeroLabs' then
			if (v["InHeroLabs"] == true and v["Name"] ~= nil) then
				iter = iter + 1	
			end
		else
			return "get_headcount()'s hero_type parameter must be either 'Released' or 'HeroLabs'"
		end
	end
	return iter
end

return p