Editing Module:PageRef

Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
local p = {}
local p = {}
local heroes_data = mw.loadJsonData("Data:HeroData.json")


-- referred pages that should not use the icon file
local function is_hero(resource_name_en)
-- only add to list if it should be true
for hero_key, hero_data in pairs(heroes_data) do
local no_file_list = {
if hero_data["Name"] == resource_name_en then
["Newscaster"] = true,
return true
["Parry"] = true,
end
["Objective"] = true,
end
["Other"] = true,
return false
["Zipline"] = true,
end
["Sandbox"] = true,
["Flex Slot"] = true,
["Creep"] = true,
["Item"] = true,
}


-- Generates appropriate filename from resource_name_localized
-- Generates appropriate filename from resource_name_en
p.get_file_name = function(frame)
p.get_file_name = function(frame)
local resource_name_localized = frame.args[1]
local resource_name_en = frame.args[1]
local alt_file_name = frame.args[2]
-- Prefix with File namespace
file_name = "File:" .. resource_name_en
--alt_file_name is optional; if not provided, assume resource_name_localized is correct
--Determine the filename to use
if alt_file_name ~= nil and alt_file_name ~= '' then
--Heroes use <hero_name>_MM.ext
file_name = alt_file_name
--Items use <item_name>.ext
else
--Abilities use <ability_name>.ext
file_name = resource_name_localized
if is_hero(resource_name_en) then
file_name = file_name .. "_MM"
--elseif is_item(resource_name_en) then
--file_name = file_name .. ""
--elseif is_ability(resource_name_en) then
--file_name = file_name .. ""
end
end
local should_use_file = no_file_list[file_name]
-- Try to grab SVG if possible
if should_use_file then
local svg_file_name = file_name .. ".svg"
return ""
if mw.title.new(svg_file_name).exists then
file_name = svg_file_name
else
file_name = file_name .. ".png"
end
end
-- Prefix with File namespace
file_name = "File:" .. file_name .. ".png"
return file_name
return file_name
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

Page included on this page: