模块:ListOfNPCs
跳转到导航
跳转到搜索
亦可参看英文模块:Module:ListOfNPCs。那边可能有更完整或更正确的信息。
Displays a sortable table of all NPCs. Invoke it from wikitext as follows:
{{#invoke:ListOfNPCs| main }}
By default, Classic, Expert, and Master Mode values are all displayed side-by-side in each table cell. To add tabs at the top for more differentiation between the modes, surround the invocation with {{npc infobox/tablestart}}
and {{npc infobox/tableend}}
.
local i18n = {
en = {
Id = 'ID',
Image = 'Image',
Name = 'Name',
Health = 'Max Health',
Damage = 'Damage',
Defense = 'Defense',
Kbresist = 'Knockback<br/>Resistance',
AI = 'AI',
Money = 'Money Dropped',
Environment = 'Environment',
Type = 'Type',
Deprecated = '(Deprecated)',
type_townNPC = 'Town NPC',
type_projectileNPC = 'Projectile',
type_critter = 'Critter',
type_friendly = 'Friendly',
type_default = 'Enemy',
},
de = {
Id = 'ID',
Image = 'Bild',
Name = 'Name',
Health = 'Max. Leben',
Damage = 'Schaden',
Defense = 'Abwehr',
Kbresist = 'Rückstoß-<br/>Widerstand',
AI = 'KI',
Money = 'Münzen',
Environment = 'Umgebung',
Type = 'Typ',
Deprecated = '(Unbenutzt)',
type_townNPC = 'Stadt-NPC',
type_projectileNPC = 'Projektil',
type_critter = 'Tier',
type_friendly = 'Friedlich',
type_default = 'Gegner',
},
fr = {
Id = 'ID',
Image = 'Image',
Name = 'Nom',
Health = 'Santé max',
Damage = 'Dégâts',
Defense = 'Défense',
Kbresist = 'Résistance<br/>au RC',
AI = 'IA',
Money = 'Pièces lâchées',
Environment = 'Environnement',
Type = 'Type',
Deprecated = '(Obsolète)',
type_townNPC = 'PNJ de ville',
type_projectileNPC = 'Projectile',
type_critter = 'Créature',
type_friendly = 'Amicale',
type_default = 'Ennemi',
},
pt = {
Id = 'ID',
Image = 'Imagem',
Name = 'Nome',
Health = 'Vida Máxima',
Damage = 'Dano',
Defense = 'Defesa',
Kbresist = 'Resistência ao<br/>Recuo',
AI = 'IA',
Money = 'Dinheiro Solto',
Environment = 'Ambiente',
Type = 'Tipo',
Deprecated = '(Descontinuado)',
type_townNPC = 'NPC de Cidade',
type_projectileNPC = 'Projétil',
type_critter = 'Criaturnha',
type_friendly = 'Amigável',
type_default = 'Inimigo',
},
ru = {
Id = 'ID',
Image = 'Изображение',
Name = 'Название',
Health = 'Макс. здоровья',
Damage = 'Урон',
Defense = 'Защита',
Kbresist = 'Сопротивление<br/>отбрасыванию',
AI = 'ИИ',
Money = 'Количество<br/>выпадаемых монет',
Environment = 'Биом',
Type = 'Тип',
Deprecated = '(не используется)',
type_townNPC = 'Житель',
type_projectileNPC = 'Снаряд',
type_critter = 'Живность',
type_friendly = 'Дружественный',
type_default = 'Противник',
},
zh = {
Id = 'ID',
Image = '图像',
Name = '名称',
Health = '最大生命值',
Damage = '伤害',
Defense = '防御',
Kbresist = '击退抗性',
AI = 'AI',
Money = '掉落金钱',
Environment = '环境',
Type = '类型',
Deprecated = '(废弃)',
type_townNPC = '城镇 NPC',
type_projectileNPC = '射弹',
type_critter = '小动物',
type_friendly = '友好',
type_default = '敌怪',
}
}
local trim = mw.text.trim
local data = {}
local unused = require('Module:Npcinfo/idSets').getIdSet('Unused')
local npcinfo = require('Module:Npcinfo')
local npcstat = npcinfo.stat
local npcids = npcinfo.info.IDs
local last = npcids.min
local output = mw.html.create('table'):addClass('terraria sortable lined aligncenter')
local currentFrame
local na
local lang = 'en'
local function l10n(index)
return i18n[lang] and i18n[lang][index] or i18n['en'][index]
end
local function v(value)
if value and trim(value) ~= '' then
return value
else
return na
end
end
function typeof(npcid)
if npcstat(npcid, 'townNPC') then
return l10n('type_townNPC')
elseif npcstat(npcid, 'projectileNPC') then
return l10n('type_projectileNPC')
elseif npcstat(npcid, 'critter') then
return l10n('type_critter')
elseif npcstat(npcid, 'friendly') then
return l10n('type_friendly')
else
return l10n('type_default')
end
end
function printNoCargoRow(id)
local tr = output:tag('tr')
tr:tag('td'):wikitext(id)
if unused[id] then
tr:tag('td'):attr('colspan', 10):tag('i'):addClass('note-text'):wikitext(l10n('Deprecated'))
else
for i=1, 10 do
tr:tag('td'):wikitext('???')
end
end
end
local ai_text = {} -- cache
function printRow(row)
local npcid = tonumber(row.npcid)
if npcid == 0 then
return
end
if npcid > last + 1 then
for id = last+1, npcid-1 do
printNoCargoRow(id)
end
end
local ai = v(row.ai)
if not ai_text[ai] then
ai_text[ai] = currentFrame:expandTemplate{title = 'tr', args = {ai}}
end
ai = ai_text[ai]
local tr = output:tag('tr')
tr:tag('td'):wikitext(npcid)
tr:tag('td'):wikitext(v(row.image))
tr:tag('td'):wikitext(v(row.name))
tr:tag('td'):wikitext(v(row.life))
tr:tag('td'):wikitext(v(row.damage))
tr:tag('td'):wikitext(v(row.defense))
tr:tag('td'):wikitext(v(row.knockback))
tr:tag('td'):wikitext(ai)
tr:tag('td'):wikitext(v(row.money))
if row.environment and trim(row.environment) ~= '' then
tr:tag('td'):wikitext(v(currentFrame:callParserFunction('#lstmaptemp',row.environment, 'npc_infobox/environment', '/', ' / ')))
else
tr:tag('td'):wikitext(na)
end
tr:tag('td'):wikitext(typeof(npcid))
last = npcid
end
return {
main=function(frame)
currentFrame = frame
lang = frame:expandTemplate{title = 'lang'}
na = frame:expandTemplate{title = 'na', args = {'-'}}
local header = output:tag('tr')
header:tag('th'):wikitext(l10n('Id'))
header:tag('th'):wikitext(l10n('Image')):addClass('unsortable')
header:tag('th'):wikitext(l10n('Name'))
header:tag('th'):wikitext(l10n('Health')):attr('data-sort-type', 'number')
header:tag('th'):wikitext(l10n('Damage')):attr('data-sort-type', 'number')
header:tag('th'):wikitext(l10n('Defense')):attr('data-sort-type', 'number')
header:tag('th'):wikitext(l10n('Kbresist')):attr('data-sort-type', 'number')
header:tag('th'):wikitext(l10n('AI'))
header:tag('th'):wikitext(l10n('Money')):attr('data-sort-type', 'number')
header:tag('th'):wikitext(l10n('Environment'))
header:tag('th'):wikitext(l10n('Type'))
local result = mw.ext.cargo.query(
'NPCs',
'npcid,name,image,life,damage,defense,knockback,ai,money,environment',
{
groupBy = 'npcid',
orderBy = 'npcid',
where = 'npcid IS NOT NULL and npcid < 1000',
limit = 1000
}
)
for _, row in ipairs(result) do
printRow(row)
end
-- tails
for id = last+1, npcids.max do
local tr = output:tag('tr')
tr:tag('td'):wikitext(id)
if unused[id] then
tr:tag('td'):attr('colspan', 2):tag('i'):addClass('note-text'):wikitext(l10n('Deprecated'))
else
tr:tag('td'):wikitext('???')
end
end
return output
end,
}