Module:Abilities: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Saag (talk | contribs)
Created page with "local p = {} return p"
 
Saag (talk | contribs)
m Added get_ability_name function
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
local data = mw.loadJsonData("Data:AbilityCards.json")
local p = {}
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
return p

Latest revision as of 17:25, 26 October 2024

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