Module:Abilities/card: Difference between revisions

Jump to navigation Jump to search
m added errors to let us know when number of supported alt boxes is exceeded
Changed p.get_ability_card to use the new ability card template
Line 36: Line 36:
end
end


--{{#invoke:AbilityData|get_ability_card|HERO_NAME|ABILITY_NUM|ADD_LINK|NOTES}}--
--{{#invoke:Abilities/card|get_ability_card|HERO_NAME|ABILITY_NUM|ADD_LINK|NOTES}}--
--Simply calls get_ability_card_from_key with the same parameters, but with key
-- Args:
--get_ability_card and invoke_get_ability_card_key will eventually be removed, and
--   HERO_NAME (required) - Name of the hero that is found in Data:HeroData.json under "Name"
--get_ability_card_from_key will be renamed to get_ability_card
--   ABILITY_NUM (required) - Selects ability at index 1 to 4
--both routes exist temporarily as current hero pages use get_ability_card via hero name
--   ADD_LINK - Add a hyperlink to the title to the associated page
--and im currently testing via hero_key on [[User:Sur/Abrams]]
--   NOTES - User note data to include in the footer of the ability card
--on the final version with fully automated pages, hero_key will be used.
--for now, hero_name can suffice
p.get_ability_card = function(frame)
p.get_ability_card = function(frame)
local hero_name = frame.args[1]
local hero_name = frame.args[1]
Line 51: Line 49:
local hero_key = get_hero_key(hero_name)
local hero_key = get_hero_key(hero_name)
if (hero_key == nil) then return 'Hero with name' .. hero_name .. 'not found' end
return p.get_ability_card_from_key(hero_key, ability_num, add_link, notes)
return build_ability_card(hero_key, ability_num, add_link, notes)
end
end


Line 114: Line 113:
end
end


p.get_ability_card_test = function(frame)
-- Pulls data from Data:AbilityCards.json to populate Template:Ability card v2
local hero_name = frame.args[1]
function build_ability_card(hero_key, ability_num, add_link, notes, notes_source_page)
local ability_num = frame.args[2]
local add_link = frame.args[3]
local notes = frame.args[4]
local hero_key = get_hero_key(hero_name)
if (hero_key == nil) then return 'Hero with name' .. hero_name .. 'not found' end
return get_ability_card_test(hero_key, ability_num, add_link, notes)
end
 
-- Function for sandboxing potential update of entire ability card generation
-- Pulls data from Data:AbilityCards.json for a defined hero and ability index
function get_ability_card_test(hero_key, ability_num, add_link, notes, notes_source_page)
local ability = utils.get_ability_card_data(hero_key, ability_num)
local ability = utils.get_ability_card_data(hero_key, ability_num)
if(ability == nil) then  
if(ability == nil) then