VOOZH about

URL: https://minecraft.wiki/w/Module:Schematic

⇱ Module:Schematic – Minecraft Wiki


Module:Schematic

From Minecraft Wiki
Jump to navigation Jump to search
Documentation[view] [edit] [history] [purge]Jump to code ↴

This module implements the template {{schematic}}, whose documentation can be found on that page.

Dependencies

[view] [edit] [history] [purge]The above documentation is transcluded from Module:Schematic/doc.
localp={}
functionp.table(f)
localargs=f.args
ifargs[1]==nilthen
args=f:getParent().args
end
localcaption=args.captionor''
localcaptionstyle=args.captionstyleor''
localclear=args.clearor''
localfloat=args.floator''
localsize=tonumber(args.size)or32
localstyle=args.styleor''
localtablestyle=args.tablestyleor''
localsprite=require('Module:Sprite').sprite
localids=mw.loadData('Module:Schematic/data').ids
localtitles=mw.loadData('Module:Schematic/titles')
localisTable=false
ifargs[2]or''~=''then
isTable=true
end
localcategories={}
ifsize~=32then
tablestyle='--schematic-sprite-size:'..size..'px;'..tablestyle
end
localcols=0
localmaxcols=0
localschematic={}
localtitle=''
for_,cellinipairs(args)do
cell=mw.text.trim(cell)
ifisTableandcell~='-'then
cols=cols+1
ifcols>maxcolsthen
maxcols=cols
end
end
ifcell==''orcell=='air'then
ifisTablethen
table.insert(schematic,'|')
else
table.insert(schematic,'<br>')
end
elseifisTableandcell=='-'then
cols=0
table.insert(schematic,'|-')
else
locallayers={}
title={}
forlayerinmw.text.gsplit(cell,'%s*+%s*')do
localidData=ids[layer]
ifidDatathen
localimage,spriteCat=sprite{
data='Schematic/data',
iddata=idData,
scale=size/16
}
table.insert(layers,image)
table.insert(categories,spriteCat)
iftitles[layer]then
table.insert(title,1,titles[layer])
end
else
table.insert(layers,'<span class="text">'..layer..'</span>')
end
end
ifargs.textthen
table.insert(layers,'<span class="text">'..args.text..'</span>')
end
title=table.concat(title,' over ')
layers=table.concat(layers,'')
ifisTablethen
iflayers~=''then
layers='| title="'..title..'" | <div>'..layers..'</div>'
else
layers='|'
end
end
table.insert(schematic,layers)
end
end
localcaptionwidth=maxcols*(size+1)+1
ifisTablethen
table.insert(schematic,1,'{|'..'class="schematic" style="min-width:'..captionwidth..'px;'..tablestyle..'"')
table.insert(schematic,'|}')
else
if#schematic==0then
table.insert(schematic,'<br>')
end
table.insert(schematic,1,'<span class="schematic" style="'..tablestyle..'" title="'..title..'">')
table.insert(schematic,'</span>')
end
localout
ifcaption~=''orfloat~=''then
iffloat==''then
float='right'
end
ifclear==''then
clear='none'
end
ifcaptionwidth<182then
captionwidth=182
end
ifnotargs.nohelpandmw.title.getCurrentTitle().prefixedText~='Help:Schematic'then
caption='<span style="float:right;padding-left:0.5em">'..
f:expandTemplate{
title='CommentSprite',
args={
'1',
link='Help:Schematic',
title='Schematic help'
}
}..
'</span>'..caption
end
out={
'<div class="thumb t'..float..'" style="overflow: auto; clear:'..clear..';'..style..'">',
'<div class="thumbinner" style="display:inline-block;min-width:'..captionwidth..'px">\n',
table.concat(schematic,'\n'),
'\n<div class="thumbcaption" style="max-width:'..captionwidth..'px;'..captionstyle..'">\n'..caption..'</div>',
'</div>',
'</div>'
}
out=table.concat(out)
else
ifisTablethen
out=table.concat(schematic,'\n')
else
-- Inline schematic should be a single line
out=table.concat(schematic)
end
end
out=out:gsub(' style=""',''):gsub(' title=""%s*|?','')
returnout..table.concat(categories)
end
returnp
Retrieved from "https://minecraft.wiki/w/Module:Schematic?oldid=2633081"

Navigation menu