mAucun résumé des modifications |
Philo04 (discussion | contributions) m (test) |
||
Ligne 141 : | Ligne 141 : | ||
tr:tag('td'):attr('colspan', 2):tag('i'):addClass('note-text'):wikitext(i18n.Deprecated) |
tr:tag('td'):attr('colspan', 2):tag('i'):addClass('note-text'):wikitext(i18n.Deprecated) |
||
else |
else |
||
+ | tr:tag('td'):format(currentFrame:expandTemplate{title = 'ItemNameFromId', args = {id}}) |
||
tr:tag('td'):wikitext('???') |
tr:tag('td'):wikitext('???') |
||
end |
end |
Version du 5 septembre 2020 à 07:36
Documentation
Voir aussi la page anglaise du module : Module:ListOfNPCs. Elle pourra contenir des informations plus complètes et actuelles.
Aucune sous-page de documentation n'existe déjà pour ce module. En créer une maintenant.
local i18n = {
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',
}
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'):format(currentFrame:expandTemplate{title = 'ItemNameFromId', args = {id}})
tr:tag('td'):wikitext('???')
end
end
return output
end,
}