Module:Abilities

From Deadlock Wiki
Revision as of 17:25, 26 October 2024 by Saag (talk | contribs) (Added get_ability_name function)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview[edit source]

Abilities module handles any simple functions that don't require a submodule

Submodules[edit source]

Abilities - Simple functions. Eg. getting ability name

Abilities/utils - Common internal functions that are shared amongst any Abilities/ modules

Abilities/card - Generates hero ability cards

Abilities/icon - Searches for an icon based on the (English) name of the ability

Abilities/details table (WIP) - Generates details table to show raw ability data


local data = mw.loadJsonData("Data:AbilityCards.json")

local p = {}

-- returns the table of a specific item
function get_ability(hero_key, ability_num)
	local ui_data = data[hero_key]
	if(ui_data == nil) then return "Hero Not Found" end
	return ui_data[tonumber(ability_num)]
end

--{{#invoke:AbilityData|get_ability_name|HERO_NAME|ABILITY_NUM}}--
p.get_ability_name = function(frame)
	local hero_name = frame.args[1]
	local ability_num = frame.args[2]
	
	local ability = get_ability(hero_name, ability_num)
	if(ability == nil) then return "Ability Not Found" end
	return ability.Name
end

return p