Module:ListOfPossibleModifiers

--- l10n info -- local l10n_info = { ['en'] = { ['th_image'] = 'Image', ['th_name'] = 'Name', ['th_Large'] = 'Large', ['th_Massive'] = 'Massive', ['th_Dangerous'] = 'Dangerous', ['th_Savage'] = 'Savage', ['th_Sharp'] = 'Sharp', ['th_Pointy'] = 'Pointy', ['th_Tiny'] = 'Tiny', ['th_Terrible'] = 'Terrible', ['th_Small'] = 'Small', ['th_Dull'] = 'Dull', ['th_Unhappy'] = 'Unhappy', ['th_Bulky'] = 'Bulky', ['th_Shameful'] = 'Shameful', ['th_Heavy'] = 'Heavy', ['th_Light'] = 'Light', ['th_Sighted'] = 'Sighted', ['th_Rapid'] = 'Rapid', ['th_Hasty'] = 'Hasty', ['th_Intimidating'] = 'Intimidating', ['th_Deadly_ref'] = 'Ranged weapons variant', ['th_Staunch'] = 'Staunch', ['th_Awful'] = 'Awful', ['th_Lethargic'] = 'Lethargic', ['th_Awkward'] = 'Awkward', ['th_Powerful'] = 'Powerful', ['th_Mystic'] = 'Mystic', ['th_Adept'] = 'Adept', ['th_Masterful'] = 'Masterful', ['th_Inept'] = 'Inept', ['th_Ignorant'] = 'Ignorant', ['th_Deranged'] = 'Deranged', ['th_Intense'] = 'Intense', ['th_Taboo'] = 'Taboo', ['th_Celestial'] = 'Celestial', ['th_Furious'] = 'Furious', ['th_Keen'] = 'Keen', ['th_Superior'] = 'Superior', ['th_Forceful'] = 'Forceful', ['th_Broken'] = 'Broken', ['th_Damaged'] = 'Damaged', ['th_Shoddy'] = 'Shoddy', ['th_Quick'] = 'Quick', ['th_Deadly'] = 'Deadly', ['th_Agile'] = 'Agile', ['th_Nimble'] = 'Nimble', ['th_Murderous'] = 'Murderous', ['th_Slow'] = 'Slow', ['th_Sluggish'] = 'Sluggish', ['th_Lazy'] = 'Lazy', ['th_Annoying'] = 'Annoying', ['th_Nasty'] = 'Nasty', ['th_Manic'] = 'Manic', ['th_Hurtful'] = 'Hurtful', ['th_Strong'] = 'Strong', ['th_Unpleasant'] = 'Unpleasant', ['th_Weak'] = 'Weak', ['th_Ruthless'] = 'Ruthless', ['th_Frenzying'] = 'Frenzying', ['th_Godly'] = 'Godly', ['th_Demonic'] = 'Demonic', ['th_Zealous'] = 'Zealous', ['th_Legendary'] = 'Legendary', ['th_Unreal'] = 'Unreal', ['th_Mythical'] = 'Mythical', ['th_Legendary_ref'] = 'Terrarian variant', },

['fr'] = { ['th_image'] = 'Image', ['th_name'] = 'Nom', ['th_Large'] = 'Grand', ['th_Massive'] = 'Massif', ['th_Dangerous'] = 'Dangereux', ['th_Savage'] = 'Sauvage', ['th_Sharp'] = 'Aiguisé', ['th_Pointy'] = 'Pointu', ['th_Tiny'] = 'Minuscule', ['th_Terrible'] = 'Terrible', ['th_Small'] = 'Petit', ['th_Dull'] = 'Terne', ['th_Unhappy'] = 'Misérable', ['th_Bulky'] = 'Mastoc', ['th_Shameful'] = 'Coupable', ['th_Heavy'] = 'Lourd', ['th_Light'] = 'Léger', ['th_Sighted'] = 'Voyant', ['th_Rapid'] = 'Rapide', ['th_Hasty'] = 'Hâtif', ['th_Intimidating'] = 'Intimidant', ['th_Deadly_ref'] = 'Variante d\'armes à distance', ['th_Staunch'] = 'Fervent', ['th_Awful'] = 'Atroce', ['th_Lethargic'] = 'Léthargique', ['th_Awkward'] = 'Gauche', ['th_Powerful'] = 'Puissant', ['th_Mystic'] = 'Mystique', ['th_Adept'] = 'Adepte', ['th_Masterful'] = 'Autoritaire', ['th_Inept'] = 'Inepte', ['th_Ignorant'] = 'Ignorant', ['th_Deranged'] = 'Dérangé', ['th_Intense'] = 'Intense', ['th_Taboo'] = 'Tabou', ['th_Celestial'] = 'Céleste', ['th_Furious'] = 'Furieux', ['th_Keen'] = 'Appliqué', ['th_Superior'] = 'Supérieur', ['th_Forceful'] = 'Énergique', ['th_Broken'] = 'Cassé', ['th_Damaged'] = 'Endommagé', ['th_Shoddy'] = 'Exécrable', ['th_Quick'] = 'Bref', ['th_Deadly'] = 'Fatal', ['th_Agile'] = 'Agile', ['th_Nimble'] = 'Leste', ['th_Murderous'] = 'Meurtrier', ['th_Slow'] = 'Lent', ['th_Sluggish'] = 'Apathique', ['th_Lazy'] = 'Paresseux', ['th_Annoying'] = 'Ennuyeux', ['th_Nasty'] = 'Méchant', ['th_Manic'] = 'Frénétique', ['th_Hurtful'] = 'Offensant', ['th_Strong'] = 'Fort', ['th_Unpleasant'] = 'Désagréable', ['th_Weak'] = 'Faible', ['th_Ruthless'] = 'Impitoyable', ['th_Frenzying'] = 'Déchaîné', ['th_Godly'] = 'Divin', ['th_Demonic'] = 'Démoniaque', ['th_Zealous'] = 'Zélé', ['th_Legendary'] = 'Légendaire', ['th_Unreal'] = 'Irréel', ['th_Mythical'] = 'Mythique', ['th_Legendary_ref'] = 'Variante du Terrarien', },

['pt'] = { ['th_image'] = 'Imagem', ['th_name'] = 'Nome', ['th_Large'] = 'Grande', ['th_Massive'] = 'Enorme', ['th_Dangerous'] = 'Perigoso', ['th_Savage'] = 'Bárbaro', ['th_Sharp'] = 'Afiado', ['th_Pointy'] = 'Pontudo', ['th_Tiny'] = 'Minúsculo', ['th_Terrible'] = 'Terrível', ['th_Small'] = 'Pequeno', ['th_Dull'] = 'Fraco', ['th_Unhappy'] = 'Infeliz', ['th_Bulky'] = 'Volumoso', ['th_Shameful'] = 'Vergonhoso', ['th_Heavy'] = 'Pesado', ['th_Light'] = 'Luz', ['th_Sighted'] = 'Visto', ['th_Rapid'] = 'Acelerado', ['th_Hasty'] = 'Rápido', ['th_Intimidating'] = 'Intimidador', ['th_Deadly_ref'] = 'Variante das armas de ataque à distância', ['th_Staunch'] = 'Convicto', ['th_Awful'] = 'Terrível', ['th_Lethargic'] = 'Letárgico', ['th_Awkward'] = 'Estranho', ['th_Powerful'] = 'Poderoso', ['th_Mystic'] = 'Místico', ['th_Adept'] = 'Adepto', ['th_Masterful'] = 'Mestre', ['th_Inept'] = 'Incapaz', ['th_Ignorant'] = 'Ignorante', ['th_Deranged'] = 'Demente', ['th_Intense'] = 'Intenso', ['th_Taboo'] = 'Tabu', ['th_Celestial'] = 'Celestial', ['th_Furious'] = 'Furioso', ['th_Keen'] = 'Disposto', ['th_Superior'] = 'Superior', ['th_Forceful'] = 'Vigoroso', ['th_Broken'] = 'Quebrado', ['th_Damaged'] = 'Danificado', ['th_Shoddy'] = 'Pobre', ['th_Quick'] = 'Rápido', ['th_Deadly'] = 'Mortal', ['th_Agile'] = 'Ágil', ['th_Nimble'] = 'Ligeiro', ['th_Murderous'] = 'Assassino', ['th_Slow'] = 'Lento', ['th_Sluggish'] = 'Vagaroso', ['th_Lazy'] = 'Preguiçoso', ['th_Annoying'] = 'Irritante', ['th_Nasty'] = 'Nojento', ['th_Manic'] = 'Maníaco', ['th_Hurtful'] = 'Doloroso', ['th_Strong'] = 'Forte', ['th_Unpleasant'] = 'Desagradável', ['th_Weak'] = 'Fraco', ['th_Ruthless'] = 'Implacável', ['th_Frenzying'] = 'Enlouquecedor', ['th_Godly'] = 'Divino', ['th_Demonic'] = 'Demoníaco', ['th_Zealous'] = 'Zeloso', ['th_Legendary'] = 'Lendário', ['th_Unreal'] = 'Surreal', ['th_Mythical'] = 'Mítico', ['th_Legendary_ref'] = 'Variante do Terrariano', }, }

--- The following is not related to l10n. --

local getPossibleModifiers = require('Module:Possible modifiers').getPossibleModifiers

local currentFrame local lang local l10n_table

local table_output = mw.html.create('table'):addClass('terraria sortable align-center'):attr( 'id', 'possible-modifiers-table' )

local template_yes local template_no

local count = 84 -- total number of modifiers

local l10n = function(key) return l10n_table[key] or l10n_info['en'][key] end

local function createHeader local header = table_output:tag('tr') local headercell = header:tag('th') headercell:addClass('unsortable') headercell:wikitext(l10n('th_image')) header:tag('th'):wikitext(l10n('th_name')) header:tag('th'):tag('small'):wikitext(l10n('th_Large')) header:tag('th'):tag('small'):wikitext(l10n('th_Massive')) header:tag('th'):tag('small'):wikitext(l10n('th_Dangerous')) header:tag('th'):tag('small'):wikitext(l10n('th_Savage')) header:tag('th'):tag('small'):wikitext(l10n('th_Sharp')) header:tag('th'):tag('small'):wikitext(l10n('th_Pointy')) header:tag('th'):tag('small'):wikitext(l10n('th_Tiny')) header:tag('th'):tag('small'):wikitext(l10n('th_Terrible')) header:tag('th'):tag('small'):wikitext(l10n('th_Small')) header:tag('th'):tag('small'):wikitext(l10n('th_Dull')) header:tag('th'):tag('small'):wikitext(l10n('th_Unhappy')) header:tag('th'):tag('small'):wikitext(l10n('th_Bulky')) header:tag('th'):tag('small'):wikitext(l10n('th_Shameful')) header:tag('th'):tag('small'):wikitext(l10n('th_Heavy')) header:tag('th'):tag('small'):wikitext(l10n('th_Light')) header:tag('th'):tag('small'):wikitext(l10n('th_Sighted')) header:tag('th'):tag('small'):wikitext(l10n('th_Rapid')) header:tag('th'):tag('small'):wikitext(l10n('th_Hasty')) header:tag('th'):tag('small'):wikitext(l10n('th_Intimidating')) header:tag('th'):tag('small'):wikitext(l10n('th_Deadly') .. currentFrame:extensionTag{ name = 'ref', content = l10n('th_Deadly_ref'), args = {} }) header:tag('th'):tag('small'):wikitext(l10n('th_Staunch')) header:tag('th'):tag('small'):wikitext(l10n('th_Awful')) header:tag('th'):tag('small'):wikitext(l10n('th_Lethargic')) header:tag('th'):tag('small'):wikitext(l10n('th_Awkward')) header:tag('th'):tag('small'):wikitext(l10n('th_Powerful')) header:tag('th'):tag('small'):wikitext(l10n('th_Mystic')) header:tag('th'):tag('small'):wikitext(l10n('th_Adept')) header:tag('th'):tag('small'):wikitext(l10n('th_Masterful')) header:tag('th'):tag('small'):wikitext(l10n('th_Inept')) header:tag('th'):tag('small'):wikitext(l10n('th_Ignorant')) header:tag('th'):tag('small'):wikitext(l10n('th_Deranged')) header:tag('th'):tag('small'):wikitext(l10n('th_Intense')) header:tag('th'):tag('small'):wikitext(l10n('th_Taboo')) header:tag('th'):tag('small'):wikitext(l10n('th_Celestial')) header:tag('th'):tag('small'):wikitext(l10n('th_Furious')) header:tag('th'):tag('small'):wikitext(l10n('th_Keen')) header:tag('th'):tag('small'):wikitext(l10n('th_Superior')) header:tag('th'):tag('small'):wikitext(l10n('th_Forceful')) header:tag('th'):tag('small'):wikitext(l10n('th_Broken')) header:tag('th'):tag('small'):wikitext(l10n('th_Damaged')) header:tag('th'):tag('small'):wikitext(l10n('th_Shoddy')) header:tag('th'):tag('small'):wikitext(l10n('th_Quick')) header:tag('th'):tag('small'):wikitext(l10n('th_Deadly')) header:tag('th'):tag('small'):wikitext(l10n('th_Agile')) header:tag('th'):tag('small'):wikitext(l10n('th_Nimble')) header:tag('th'):tag('small'):wikitext(l10n('th_Murderous')) header:tag('th'):tag('small'):wikitext(l10n('th_Slow')) header:tag('th'):tag('small'):wikitext(l10n('th_Sluggish')) header:tag('th'):tag('small'):wikitext(l10n('th_Lazy')) header:tag('th'):tag('small'):wikitext(l10n('th_Annoying')) header:tag('th'):tag('small'):wikitext(l10n('th_Nasty')) header:tag('th'):tag('small'):wikitext(l10n('th_Manic')) header:tag('th'):tag('small'):wikitext(l10n('th_Hurtful')) header:tag('th'):tag('small'):wikitext(l10n('th_Strong')) header:tag('th'):tag('small'):wikitext(l10n('th_Unpleasant')) header:tag('th'):tag('small'):wikitext(l10n('th_Weak')) header:tag('th'):tag('small'):wikitext(l10n('th_Ruthless')) header:tag('th'):tag('small'):wikitext(l10n('th_Frenzying')) header:tag('th'):tag('small'):wikitext(l10n('th_Godly')) header:tag('th'):tag('small'):wikitext(l10n('th_Demonic')) header:tag('th'):tag('small'):wikitext(l10n('th_Zealous')) header:tag('th'):tag('small'):wikitext(l10n('th_Legendary')) header:tag('th'):tag('small'):wikitext(l10n('th_Unreal')) header:tag('th'):tag('small'):wikitext(l10n('th_Mythical')) header:tag('th'):tag('small'):wikitext(l10n('th_Legendary') .. currentFrame:extensionTag{ name = 'ref', content = l10n('th_Legendary_ref'), args = {} })

return end

local function getPossibleModifiersSet(itemid) -- prepare set local pm_set = {} for i=1, count do		pm_set[i] = false end -- fill set local pm_table = getPossibleModifiers(itemid) for _, modifierid in ipairs(pm_table) do		pm_set[modifierid] = true end return pm_set end

local function printRow(rowData) local row = mw.html.create('tr') row:tag('td'):wikitext(rowData.image) local rowcell = row:tag('td') rowcell:attr('align', 'left') rowcell:wikitext(currentFrame:expandTemplate{ title = 'eil', args = { rowData.name, small = 'n' } }) local possible_modifiers = getPossibleModifiersSet(rowData.itemid) for i=1, count do		if i 80 then -- skip accessory modifiers local rowcell = row:tag('td') if possible_modifiers[i] then rowcell:wikitext(template_yes) else rowcell:wikitext(template_no) end end end return tostring(row) end

- -- main return object return {

go = function(frame) -- init cache currentFrame = frame lang = frame.args['lang'] or frame:expandTemplate{ title='lang' } l10n_table = l10n_info[lang] or l10n_info['en'] local cargolimit = frame.args['limit'] template_yes = currentFrame:expandTemplate{ title = 'yes', args = {} } template_no = currentFrame:expandTemplate{ title = 'no', args = {} } createHeader -- There are more than 5000 items now. local result = mw.ext.cargo.query(		'Items',		'itemid, name, image',		{			groupBy = 'itemid',			orderBy = 'name',			where = 'unobtainable IS NULL AND (type HOLDS "weapon" OR listcat HOLDS "weapon items") AND damagetype IS NOT NULL AND damagetype != "Throwing" AND internalname != "None" ',			limit = cargolimit		}	) for _, row in ipairs(result) do		table_output:wikitext(printRow(row)) end -- prepend an empty node in order to be able to select for styling the div that is automatically created around the table by Extension:Crusher local prepend = mw.html.create('div'):attr( 'id', 'possible-modifiers-table-prepend' )

return tostring(prepend) .. tostring(table_output)

end, }