Module:AbilityData/hero: Difference between revisions
Jump to navigation
Jump to search
m p. prefix func name |
m preprocesses |
||
Line 24: | Line 24: | ||
local ability_name_localized_encoded = util_module.url_encode(ability_name_localized) | local ability_name_localized_encoded = util_module.url_encode(ability_name_localized) | ||
local notes_str_localized = dictionary_module.translate('Notes', nil, '') | local notes_str_localized = dictionary_module.translate('Notes', nil, '') | ||
local tab_name = "|-|(" .. ability_num .. ")" .. ability_name_en .. "=" | local tab_name = "|-|(" .. ability_num .. ") " .. ability_name_en .. "=" | ||
local transcluded_notes_from = "<i>" .. dictionary_module.translate_embed( | local transcluded_notes_from = "<i>" .. dictionary_module.translate_embed( | ||
'TranscludedNotesFrom', | 'TranscludedNotesFrom', | ||
'https://en.wikipedia.org/wiki/Help:Transclusion', | 'https://en.wikipedia.org/wiki/Help:Transclusion', | ||
'[[User:Sur/'..ability_name_localized..'/'..notes_str_localized..']]', | '[[User:Sur/'..ability_name_localized..'/'..notes_str_localized..']]', | ||
'https://deadlocked.wiki/index.php?title=User:Sur/'..ability_name_localized_encoded..'/'..notes_str_localized..' | 'https://deadlocked.wiki/index.php?title=User:Sur/'..ability_name_localized_encoded..'/'..notes_str_localized..'&action=edit' | ||
) .. "</i>" | ) .. "</i>" | ||
Line 36: | Line 36: | ||
ret = ret .. tab_name .. tab_content | ret = ret .. tab_name .. tab_content | ||
end | end | ||
ret = "<tabber>" .. ret .. "</tabber>" | |||
return frame:preprocess(ret) | |||
end | end | ||
return p | return p |
Revision as of 19:03, 14 October 2024
Documentation for this module may be created at Module:AbilityData/hero/doc
local ability_module = require("Module:AbilityData")
local dictionary_module = require("Module:Dictionary")
local lang_module = require("Module:Lang")
local util_module = require("Module:Utilities")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local p = {}
-- Write each of the hero's ability cards in a tab of a tabber
function p.write_hero_abilities(frame)
local hero_key = frame.args[1]
--Determine the hero's abilities
local hero_data = heroes_data[hero_key]
if (hero_data==nil) then return "Hero key "..hero_key.." not found" end
local abilities_data = hero_data["BoundAbilities"]
if (abilities_data==nil) then return "Hero key"..hero_key.." has no BoundAbilities" end
local ret = ""
for ability_num, ability_data in pairs(abilities_data) do
local ability_key = ability_data["Key"]
local ability_name_en = ability_data["Name"]
local ability_name_localized = lang_module.get_string(ability_key)
local ability_name_localized_encoded = util_module.url_encode(ability_name_localized)
local notes_str_localized = dictionary_module.translate('Notes', nil, '')
local tab_name = "|-|(" .. ability_num .. ") " .. ability_name_en .. "="
local transcluded_notes_from = "<i>" .. dictionary_module.translate_embed(
'TranscludedNotesFrom',
'https://en.wikipedia.org/wiki/Help:Transclusion',
'[[User:Sur/'..ability_name_localized..'/'..notes_str_localized..']]',
'https://deadlocked.wiki/index.php?title=User:Sur/'..ability_name_localized_encoded..'/'..notes_str_localized..'&action=edit'
) .. "</i>"
local tab_content = transcluded_notes_from
ret = ret .. tab_name .. tab_content
end
ret = "<tabber>" .. ret .. "</tabber>"
return frame:preprocess(ret)
end
return p