Dota 2 Wiki
Advertisement

Documentação para Módulo:Show Pular para o código ↴ [ editar | atualizar ]

Reality Rift icon
▶️ Planeshift.
A documentação deste módulo pode ser encontrada em Predefinição:Show.
Você pode ser redirecionado para uma wiki em outro idioma, se de não houver tradução disponível.


Dependencies

local p = {}
local cargo = mw.ext.cargo
local getArgs = require('Module:Arguments').getArgs

local i18n = {
  error = {
    incomplete_input = 'Missing or incomplete input'
  }
}


local function query(table, page, property)
  property = string.gsub(mw.ustring.lower(property), ' ', '_')
  return cargo.query(table, property, { where='_pageName="' .. page .. '"', groupBy='_pageID' })[1][property]
end

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

function p._main(args)
  assert(args[1] and args[2] and args[3], i18n.error.incomplete_input)
  local type = string.lower(args[1])
  
  if type == 'h' then
    return query('heroes', args[2], args[3])
  elseif type == 't' then
    return query('talents', args[2], args[3])
  elseif type == 'i' then
    return query('items', args[2], args[3])
  elseif type == 'u' then
    return query('units', args[2], args[3])
  elseif type == 'a' then
    assert(args[4], i18n.error.incomplete_input)
    args[4] = string.gsub(string.lower(args[4]), ' ', '_')
    
    if args[4]:find('trait') or args[4]:find('value') then
      return cargo.query('abilities_traits', args[4], { where='_pageName LIKE "' .. args[2] .. '%" AND title="' .. args[3] .. '"', groupBy='_pageName, title' })[1][args[4]]
    elseif args[4]:find('buff') or args[4]:find('debuff') then
      return cargo.query('abilities_buffs', args[4], { where='_pageName LIKE "' .. args[2] .. '%" AND title="' .. args[3] .. '"', groupBy='_pageName, title' })[1][args[4]]
    else
      return cargo.query('abilities', args[4], { where='source="' .. args[2] .. '" AND title="' .. args[3] .. '"', groupBy='source, title' })[1][args[4]]
    end
  end
end


return p
Advertisement