モジュール:DLCLink

提供:ARK Wiki
ナビゲーションに移動 検索に移動

このモジュールについての説明文ページを モジュール:DLCLink/doc に作成できます

-- Checks if the name contains a DLC-suffix and changes it to the according DLC-icon, then returns a link to name.

local p = {}

local tryMatch = require('Module:DissectDlcItemName').tryMatch


function p.link(name, noDlcIcon)
  -- Look up DLC icon info for the name with DissectDlcItemName
  local info = tryMatch(name)
  if info then
  	return '[['..name..'|'..info.displayName..']]'.. ((not noDlcIcon) and ' [[File:'..info.dlcIcon..'|16px|link='..info.dlcArticle..'|alt=('..info.dlcArticle..')]]' or '')
  end

  -- If no dlc was found, use generic approach
  local title = mw.title.new(name)
  if title == nil then
    return 'page not found: ' .. name
  end
  local link = (#title.nsText > 0) and (title.fullText .. '|' .. title.text) or title.text
  return '[['..link..']]'
end


return p