Aller au contenu

« Module:Fiche de créature » : différence entre les versions

m
aucun résumé des modifications
Kharmitch (discussion | contributions)
Aucun résumé des modifications
Kharmitch (discussion | contributions)
mAucun résumé des modifications
 
(6 versions intermédiaires par le même utilisateur non affichées)
Ligne 28 : Ligne 28 :
if not value then
if not value then
value = part.defaultvalue
value = part.defaultvalue
end
if not value then
return nil
if value == nil then
end
return nil
end
end
Ligne 43 : Ligne 42 :
function p.buildlist(part)
function p.buildlist(part)
local title = part.title
local title = part.title
local items = part.items
local prefix = part.prefix
if not title or not items then
local maxitems = part.max
if not title or not prefix or not maxitems then
return nil
return nil
end
end


-- create items
-- create items
local expandeditems = {}
local items = {}
for k, row in ipairs(items) do
for i = 1, maxitems do
local v = p.buildblock(row)
local v = p.builditem({ value = prefix..i })
if v then
if not v then
table.insert(expandeditems, v)
break
end
end
table.insert(items, v)
end
end
if (#expandeditems == 0) then
if #items == 0 then
return nil
return nil
end
end
items = expandeditems


-- create list
-- create list
Ligne 92 : Ligne 93 :
end
end
icon = icons._build({ icon })
icon = icons._build({ icon, 'petit' })
local row = mw.html.create('tr')
local row = mw.html.create('tr')
Ligne 151 : Ligne 152 :
tab:allDone()
tab:allDone()
return tab
return tab
end
function builddescription()
imageFilename = localdata['image'] or ''
imageUpright = localdata['upright'] or '1'
description = localdata['description'] or ''
text = '[[Fichier:'..imageFilename..'|frameless|center|upright='..imageUpright..']]'
text = text..'\n'..description..'\n'
description = mw.html.create('div')
:addClass('creature-card-description')
:wikitext(text)
:done()
return tostring(description)
end
end


Ligne 179 : Ligne 164 :
['row'] = p.buildrow,
['row'] = p.buildrow,
['list'] = p.buildlist,
['list'] = p.buildlist,
['item'] = p.builditem,
}
}
Ligne 192 : Ligne 176 :
moduledata.name = localdata.modulename
moduledata.name = localdata.modulename
local data = mw.html.create('div')
local card = mw.html.create('div')
:addClass('creature-card-data')
for i, j in pairs(moduledata.parts) do
for i, j in pairs(moduledata.parts) do
data:node(p.buildblock(j))
card:node(p.buildblock(j))
end
end
-- construction de la fiche
local card = mw.html.create('div')
:addClass('creature-card')
:node(builddescription())
:node(data)
return tostring(card)
return tostring(card)
end
end


return p
return p
Bureaucrate, commentadmin, emailconfirmed, Administrateurs d’interface, staff, Administrateur
62 737

modifications