Módulo:ChiselLink
Ir para navegação
Ir para pesquisar
Documentação do módulo
Esta documentação é transcluída de Predefinição:Sem documentação/doc. [editar] [atualizar]
Este módulo não possui nenhuma documentação. Por favor, considere adicionar uma documentação em Módulo:ChiselLink/doc. [editar]
Módulo:ChiselLink's a função main é invocada por Predefinição:Chisel link.
local links = {
objeto = 'https://chisel.weirdgloop.org/gazproj/mrid',
npc = 'https://chisel.weirdgloop.org/gazproj/mrnd',
['cenário'] = 'https://chisel.weirdgloop.org/gazproj/mrod'
}
local labels = {
objeto = 'MRID',
npc = 'MRND',
['cenário'] = 'MROD'
}
local p = {}
function p.main(frame)
local args = frame:getParent().args
return p._main(args[1], args[2])
end
function p._main(idtype, ids)
if not (type(ids) == 'string' and ids:match('^[ 0-9,]+$')) then
return ''
end
local _ids = mw.text.split(mw.text.trim(ids), '%s*,%s*')
local _type= string.lower( mw.text.split(mw.text.trim(idtype), '%s+')[1] )
if not links[_type] then
return ''
end
if #_ids == 0 then
return ''
elseif #_ids == 1 then
if tonumber(_ids[1]) then
return string.format(' [%sid?%s#%s-%s %s]', links[_type], _ids[1], math.max(_ids[1]-15,0), _ids[1]+15, labels[_type])
else
return string.format(' [%sid#%s %s]', links[_type], _ids[1], labels[_type])
end
else
local ret = ''
for _,i in ipairs(_ids) do
if tonumber(i) then
ret = ret .. string.format(' [%sid?%s#%s-%s %s%s]', links[_type], i, math.max(i-15,0), i+15, labels[_type], i)
else
ret = ret .. string.format(' [%sid#%s %s%s]', links[_type], i, labels[_type], i)
end
end
return ret
end
end
return p