Module:Grid/FTAElement

local p = {} local g = require("Module:Common") local s = require("Module:Sprite")

elemtable = { ['Hydrogen'] = {1, 'H'}; ['Helium'] = {2, 'He'}; ['Lithium'] = {3, 'Li'}; ['Beryllium'] = {4, 'Be'}; ['Boron'] = {5, 'B'}; ['Carbon'] = {6, 'C'}; ['Nitrogen'] = {7, 'N'}; ['Oxygen'] = {8, 'O'}; ['Fluorine'] = {9, 'F'}; ['Neon'] = {10, 'Ne'}; ['Sodium'] = {11, 'Na'}; ['Magnesium'] = {12, 'Mg'}; ['Aluminium'] = {13, 'Al'}; ['Silicon'] = {14, 'Si'}; ['Phosphorus'] = {15, 'P'}; ['Sulfur'] = {16, 'S'}; ['Chlorine'] = {17, 'cl'}; ['Argon'] = {18, 'Ar'}; ['Potassium'] = {19, 'K'}; ['Calcium'] = {20, 'Ca'}; ['Scandium'] = {21, 'Sc'}; ['Titanium'] = {22, 'Ti'}; ['Vanadium'] = {23, 'V'}; ['Chromium'] = {24, 'Cr'}; ['Manganese'] = {25, 'Mn'}; ['Iron'] = {26, 'Fe'}; ['Cobalt'] = {27, 'Co'}; ['Nickel'] = {28, 'Ni'}; ['Copper'] = {29, 'Cu'}; ['Zinc'] = {30, 'Zn'}; ['Gallium'] = {31, 'Ga'}; ['Germanium'] = {32, 'Ge'}; ['Arsenic'] = {33, 'As'}; ['Selenium'] = {34, 'Se'}; ['Bromine'] = {35, 'Br'}; ['Krypton'] = {36, 'Kr'}; ['Rubidium'] = {37, 'Rb'}; ['Strontium'] = {38, 'Sr'}; ['Yttrium'] = {39, 'Y'}; ['Zirconium'] = {40, 'Zr'}; ['Niobium'] = {41, 'Nb'}; ['Molybdenum'] = {42, 'Mo'}; ['Technetium'] = {43, 'Tc'}; ['Ruthenium'] = {44, 'Ru'}; ['Rhodium'] = {45, 'Rh'}; ['Palladium'] = {46, 'Pd'}; ['Silver'] = {47, 'Ag'}; ['Cadmium'] = {48, 'Cd'}; ['Indium'] = {49, 'In'}; ['Tin'] = {50, 'Sn'}; ['Antimony'] = {51, 'Sb'}; ['Tellurium'] = {52, 'Te'}; ['Iodine'] = {53, 'I'}; ['Xenon'] = {54, 'Xe'}; ['Caesium'] = {55, 'Cs'}; ['Barium'] = {56, 'Ba'}; ['Hafnium'] = {72, 'Hf'}; ['Tantalum'] = {73, 'Ta'}; ['Tungsten'] = {74, 'W'}; ['Rhenium'] = {75, 'Re'}; ['Osmium'] = {76, 'Os'}; ['Iridium'] = {77, 'Ir'}; ['Platinum'] = {78, 'Pt'}; ['Gold'] = {79, 'Au'}; ['Mercury'] = {80, 'Hg'}; ['Thallium'] = {81, 'Tl'}; ['Lead'] = {82, 'Pb'}; ['Bismuth'] = {83, 'Bi'}; ['Polonium'] = {84, 'Po'}; ['Astatine'] = {85, 'At'}; ['Radon'] = {86, 'Rn'}; }

tablemap = {}

for name, data in pairs(elemtable) do	local elem = {data[1], name, data[2]} tablemap[string.lower(name)] = elem tablemap[string.lower(data[2])] = elem end function p.makeElement(idx, name, link, tooltip, top, left, fill) local output = '' .. s.makeSprite('FTAPeriodicTable.png', idx, 64, 1024, link, name) .. ' '	return output end function p.main(frame) local frame, args = g.getFrameAndArgs(frame) if not g.isGiven(args.name) then return '' end local data = tablemap[string.lower(args.name)] if data == nil then return '' end local tooltip = data[2] .. ' [' .. data[3] .. ']'	local link = args.link if not g.isGiven(link) then link = data[2] end local top = 0 if g.isGiven(args.top) and tonumber(args.top) then top = tonumber(args.top) end local left = 0 if g.isGiven(args.left) and tonumber(args.left) then left = tonumber(args.left) end return p.makeElement(data[1] - 1, data[2], link, tooltip, top, left, args.fill) end return p