Dota 2 Wiki

你现在尚未登录,许多功能可能无法正常使用,若已有账号,请登录,若没有,请先注册Twitch账号
目前我们有非常多的待翻译条目,你也可以看一下目前我们需要优先处理的有哪些目前我们有非常多的待翻译条目,你也可以看一下目前我们需要优先处理的有哪些英雄页面的攻略、克制和物品页面的推荐英雄、小贴士等均为社区玩家编写的,你也可以把自己的心得写上去哦。英雄页面的攻略、克制和物品页面的推荐英雄、小贴士等均为社区玩家编写的,你也可以把自己的心得写上去哦。看不懂技能的buff/debuff是哪个跟哪个?鼠标移动到名称上就能看到游戏内显示的名字和描述了。看不懂技能的buff/debuff是哪个跟哪个?鼠标移动到名称上就能看到游戏内显示的名字和描述了。目前我們沒有善於製作其他中文變體的人員,如果您善於或擁有相關技術,請幫忙補充其他中文變體的空白。目前我們沒有善於製作其他中文變體的人員,如果您善於或擁有相關技術,請幫忙補充其他中文變體的空白。

了解更多

Dota 2 Wiki
Advertisement
Reality Rift icon
▶️ Planeshift.
该module的文档可以在Template:SkillListLite找到。
You may be forwarded to another wiki language, in case a translation is not available.



--------------------------------------------------------------------------------
-- Imports
--------------------------------------------------------------------------------

local cargo = mw.ext.cargo
local aicon = require( 'Module:Ability icon' )._main
local color = require( 'Module:Color' )._main
local getArgs = require('Module:Arguments').getArgs

--------------------------------------------------------------------------------
-- Strings
--------------------------------------------------------------------------------

local i18n = {
  error = {
    category = 'Category:有脚本错误的页面',
    prefix = 'Lua错误',
    input_error = '缺少或未完成输入',
    no_data = '没有找到"%s - %s"的Cargo数据',
    old_ability = '"%s - %s"是一个旧的技能。[[Category:包含旧的技能的页面]]'
  }
}

--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------

local h = {}

--- Make a new li object.
-- @param text: The object's text.
-- @param background: The object's background-color.
function h.make_li(text, background)
  return mw.html.create('li')
    :addClass('skilllist-lite')
    :css('background-color', background)
    :wikitext(text)
end

--- Creates an error that fits into the list.
-- @param message: The error message.
function h.li_error(message)
  return h.make_li(string.format('%s: %s.[[%s]]', i18n.error.prefix, message, i18n.error.category), '#c00')
end

--------------------------------------------------------------------------------
-- Template
--------------------------------------------------------------------------------

local p = {}

function p.main(frame)
  local args = getArgs(frame, {
    wrappers = {
      'Template:SkillListLite'
    }
  })
  return p._main(args)
end

function p._main(args)
  -- Check the input. We can't use assert() here since we want our custom error.
  if not args and args.source and args.name then
    return h.li_error(i18n.error.input_error)
  end

  -- Get the ability's data.
  local data = cargo.query( 'abilities', 'image, type, game', {
    where='uid="' .. args.source .. '&' .. args.name .. '"',
    groupBy='source, title',
    limit=1
  } )[1]
  if not data then return h.li_error(string.format(i18n.error.no_data, args.source, args.name)) end
  if #args.name > 0 and #data.game > 0 then return h.li_error(string.format(i18n.error.old_ability, args.source, args.name)) end
  data.image = aicon(args, data)

  local image_link = string.format('[[%s|24px|link=%s#%s]]', data.image, args.source, args.name)
  local source_link = string.format('[[%s|%s]]', args.source, (args.sourcetext or args.source))
  local name_link = string.format('[[%s#%s|%s]]', args.source, args.name, (args.nametext or args.name))

  return h.make_li((image_link .. ' ' .. source_link .. ' – ' .. name_link), color{data.type})
end

--------------------------------------------------------------------------------
-- Return
--------------------------------------------------------------------------------

return p
Advertisement