Module:Link

local p = {}

local data = mw.loadData( 'Module:Link/data' )

function p.heroLink(frame) return p.heroLinkArg(frame.args[1]) end

-- To be accessible from other modules function p.heroLinkArg(arg) local heroText = arg if data["heroes"][heroText] ~= nil then heroText = data["heroes"][heroText] end return heroText end

function p.heroClass(frame) local hero = frame:getParent.args[1] if hero == nil then hero = "Iron Man" end local class = frame:getParent.args['class'] local s = "" if class ~= nil then for i in string.gmatch(class, "%w+") do     s = s.."" end s = s.." " end s = s..""..hero.."" return s end

function p.enemyLink(frame) local enemyText = frame.args[1] if data["enemies"][enemyText] ~= nil then enemyText = data["enemies"][enemyText] end return enemyText end

-- Get organizations list function p.organizations(frame) local org = frame:getParent.args[1] local i = 2 if data["organizations"][org] ~= nil then org = data["organizations"][org] end while frame:getParent.args[i] ~= nil do   local o = frame:getParent.args[i] i = i + 1 if data["organizations"][o] ~= nil then o = data["organizations"][o] end org = org..", "..o end -- If this is hero alt page remove categories. -- Only hero alt pages use template 'Hero Actions' local content = mw.title.getCurrentTitle:getContent if string.find(content, "Hero Actions") then org, n = string.gsub(org, " %[%[Category(.-)%]%]", "") end return org end

function p.types(frame) local type = frame:getParent.args[1] local s = "" if type ~= nil then s = ""..type.."" local i = 2 while frame:getParent.args[i] ~= nil do     local t = frame:getParent.args[i] i = i + 1 s = s.." "..t.."" end end return s end

function p.partOf(frame) local partof = frame.args[1] if data["part_of"][partof] ~= nil then partof = data["part_of"][partof] end return partof end

function p.typeCategory(frame) local type = frame.args[1] if data["type_category"][type] ~= nil then type = data["type_category"][type] else type = "?" end return type end

function p.empowered(frame) local name = frame.args[1] if data["eiso"][name] ~= nil then eiso = data["eiso"][name] else eiso = name.." Empowered Iso-8" end return eiso end

function p.augmented(frame) local name = frame.args[1] if data["aiso"][name] ~= nil then aiso = data["aiso"][name] else aiso = name.." Augmented Iso-8" end return aiso end

return p