Module:Autovirusbox and Module:Autovirusbox/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
Artoria2e5 (talk | contribs) Wasted ten minutes of my life. Lmao. |
Artoria2e5 (talk | contribs) Multi-infra experiment, destroyed by how taxobox/core works. |
||
Line 40: | Line 40: | ||
-- set the taxobox parameters determined by this function |
-- set the taxobox parameters determined by this function |
||
-- ------------------------------------------------------ |
-- ------------------------------------------------------ |
||
local autoTaxon, autoTaxonType, |
local autoTaxon, autoTaxonType, infraTaxa, infraTaxaRanks, targetTaxon, targetTaxonRank = l.paramChk(frame, taxon, parent, species, strain, serotype, virus) |
||
-- set default taxobox name/title |
-- set default taxobox name/title |
||
local italicsRequired = frame:expandTemplate{ title = 'Is italic taxon', args = {targetTaxonRank, virus='yes'} } == 'yes' and args["italic_title"] ~= "no" |
local italicsRequired = frame:expandTemplate{ title = 'Is italic taxon', args = {targetTaxonRank, virus='yes'} } == 'yes' and args["italic_title"] ~= "no" |
||
Line 71: | Line 71: | ||
end |
end |
||
-- embolden lowest rank |
-- embolden lowest rank |
||
-- oops, here goes the problem |
|||
if infraTaxon ~= '' then |
if infraTaxon ~= '' then |
||
infraTaxon = "'''"..infraTaxon.."'''" |
infraTaxon = "'''"..infraTaxon.."'''" |
||
Line 147: | Line 148: | ||
function l.paramChk(frame, taxon, parent, species, strain, serotype, virus) |
function l.paramChk(frame, taxon, parent, species, strain, serotype, virus) |
||
-- set target taxon and infra-taxon |
-- set target taxon and infra-taxon |
||
local |
local infraTaxa = {} |
||
local |
local infraTaxaRanks = {} |
||
local targetTaxon |
local targetTaxon = '' |
||
local targetTaxonRank |
local targetTaxonRank |
||
-- populate infraTaxa |
|||
⚫ | |||
infraTaxa[#infraTaxa+1] = virus |
|||
infraTaxaRanks[#infraTaxaRanks+1] = 'virus' |
|||
end |
|||
⚫ | |||
infraTaxa[#infraTaxa+1] = serotype |
|||
infraTaxaRanks[#infraTaxaRanks+1] = 'serotype' |
|||
end |
|||
if strain ~= '' then |
if strain ~= '' then |
||
infraTaxa[#infraTaxa+1] = strain |
|||
infraTaxaRanks[#infraTaxaRanks+1] = 'strain' |
|||
⚫ | |||
targetTaxonRank = infraTaxonRank |
|||
⚫ | |||
infraTaxon = serotype |
|||
infraTaxonRank = 'serotype' |
|||
targetTaxon = infraTaxon |
|||
targetTaxonRank = infraTaxonRank |
|||
⚫ | |||
infraTaxon = virus |
|||
infraTaxonRank = 'virus' |
|||
targetTaxon = infraTaxon |
targetTaxon = infraTaxon |
||
targetTaxonRank = infraTaxonRank |
targetTaxonRank = infraTaxonRank |
||
end |
|||
-- populate targetTaxon using lowest |
|||
if #infraTaxa > 1 then |
|||
⚫ | |||
targetTaxonRank = infraTaxaRanks[#infraTaxaRanks] |
|||
elseif species ~= '' then |
elseif species ~= '' then |
||
targetTaxon = species |
targetTaxon = species |
||
Line 178: | Line 184: | ||
local autoTaxonType = 'ERROR' |
local autoTaxonType = 'ERROR' |
||
if taxon ~= '' then |
if taxon ~= '' then |
||
if parent..species.. |
if parent..species..(table.concat(infraTaxa, '')) == '' then |
||
autoTaxon = taxon |
autoTaxon = taxon |
||
autoTaxonType = 'TAXON' |
autoTaxonType = 'TAXON' |
||
end |
end |
||
elseif parent ~= '' and |
elseif parent ~= '' and (species ~='' or #infraTaxa > 1) then |
||
autoTaxon = parent |
autoTaxon = parent |
||
autoTaxonType = 'PARENT' |
autoTaxonType = 'PARENT' |
||
end |
end |
||
⚫ | |||
-- check for multiple infra-taxa |
|||
-- This is not this module's limitation: go blame Template:Taxobox/core! |
|||
local count = 0 |
|||
if strain ~= '' then count = count + 1 end |
|||
if serotype ~= '' then count = count + 1 end |
|||
if virus ~= '' then count = count + 1 end |
|||
if count > 1 then autoTaxonType = 'ERROR' end |
|||
⚫ | |||
end |
end |
||