Документация
См. также этот модуль на английском языке: Module:ListOfNPCs. В нём может содержаться более полная или подробная информация.
Документация для этого модуля отсутствует. Создайте её.
local i18n = {
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 = 'Противник',
}
local trim = mw.text.trim
local id_start, id_end = -65, 662 -- as in 1.4.0.5
local data={}
local unused = require('Module:Npcinfo/idSets').getIdSet('Unused')
local npcstat = require('Module:Npcinfo').stat
local last = id_start
local output = mw.html.create('table'):addClass('terraria sortable lined aligncenter')
local currentFrame
local na
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 i18n.type_townNPC
elseif npcstat(npcid, 'projectileNPC') then
return i18n.type_projectileNPC
elseif npcstat(npcid, 'critter') then
return i18n.type_critter
elseif npcstat(npcid, 'friendly') then
return i18n.type_friendly
else
return i18n.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(i18n.Deprecated)
else
tr:tag('td'):wikitext('???')
tr:tag('td'):wikitext('???')
tr:tag('td'):wikitext('???')
tr:tag('td'):wikitext('???')
tr:tag('td'):wikitext('???')
tr:tag('td'):wikitext('???')
tr:tag('td'):wikitext('???')
tr:tag('td'):wikitext('???')
tr:tag('td'):wikitext('???')
tr:tag('td'):wikitext('???')
end
end
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 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(v(row.ai))
tr:tag('td'):wikitext(v(row.money))
tr:tag('td'):wikitext(v(currentFrame:callParserFunction('#lstmaptemp',row.environment, 'npc_infobox/environment', '/', ' / ')))
tr:tag('td'):wikitext(typeof(npcid))
last = npcid
end
return {
main=function(frame)
currentFrame = frame
na = frame:expandTemplate{title = 'na', args = {'-'}}
local header = output:tag('tr')
header:tag('th'):wikitext(i18n.Id)
header:tag('th'):wikitext(i18n.Image)
header:tag('th'):wikitext(i18n.Name)
header:tag('th'):wikitext(i18n.Health)
header:tag('th'):wikitext(i18n.Damage)
header:tag('th'):wikitext(i18n.Defense)
header:tag('th'):wikitext(i18n.Kbresist)
header:tag('th'):wikitext(i18n.AI)
header:tag('th'):wikitext(i18n.Money)
header:tag('th'):wikitext(i18n.Environment)
header:tag('th'):wikitext(i18n.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, id_end 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(i18n.Deprecated)
else
tr:tag('td'):wikitext('???')
end
end
return output
end,
}