function on.construction() pse_db = { {"Hydrogen","H",1,1.00784,1,13.598433,2.20,-259.2,-252.77,0.0000899,"1s" .. string.uchar(185),"Henry Cavendish",1766,4,3,"+I, -I"}, {"Helium","He",2,4.002602,4,24.587387,"no EN",-272.2,-268.9,0.0001787,"1s" .. string.uchar(178),"Pierre Janssen",1868,4,2,"0"}, {"Lithium","Li",3,6.941,7,5.391719,0.98,180.5,1342,0.535,"[He] 2s" .. string.uchar(185),"Johann August Arfvedson",1817,2,2,"+I"}, {"Beryllium","Be",4,9.012182,8,9.32270,1.57,1287,2471,1.848,"[He] 2s" .. string.uchar(178),"Nicholas-Louis Vauquelin",1797,4,1,"+III"}, {"Boron","B",5,10.811,9,8.29802,2.04,2200,2550,2.46,"[He] 2s" .. string.uchar(178) .. " 2p" .. string.uchar(185),"J.L. Gay-Lussac and L.J. Thenard",1808,5,2,"+III"}, {"Carbon","C",6,12.011,1,11.26030,2.55,3550,4827,2.26,"[He] 2s" .. string.uchar(178) .. " 2p" .. string.uchar(178),"someone","ancient times",4,3,"+II, +IV, -IV"}, {"Nitrogen","N",7,14.0067,1,14.5341,3.04,-209.86,-195.8,0.0012506,"[He] 2s" .. string.uchar(178) .. " 2p" .. string.uchar(179),"Daniel Rutherford",1772,4,4,"+I, -I, +II, -II,+III, -III, +IV, V"}, {"Oxygen","O",8,15.999,1,13.61805,3.44,-218.4,-183,0.001429,"[He] 2s" .. string.uchar(178) .. " 2p" .. string.uchar(8308),"Carl Wilhelm Scheele",1772,3,4,"-II"}, {"Fluorine","F",9,18.998403,1,17.4228,3.98,-219.62,-188,0.001696,"[He] 2s" .. string.uchar(178) .. " 2p" .. string.uchar(8309),"Henri Moissan",1886,3,2,"-I"}, {"Neon","Ne",10,20.1797,4,21.56454,"no EN",-248.67,-246.048,0.0009,"[He] 2s" .. string.uchar(178) .. " 2p" .. string.uchar(8310),"Sir William Ramsey and M.T. Travers",1898,1,3,"0"}, {"Sodium","Na",11,22.989769,7,5.139076,0.93,97.81,882.9,0.968,"[Ne] 3s" .. string.uchar(185),"Sir Humphrey Davy",1807,2,3,"+I"}, {"Magnesium","Mg",12,24.305,8,7.646235,1.31,650,1090,1.738,"[Ne] 3s" .. string.uchar(178),"Sir Humphrey Davy",1808,4,5,"+II"}, {"Aluminum","Al",13,26.981539,3,5.985768,1.61,660.32,2518.85,2.7,"[Ne] 3s" .. string.uchar(178) .. " 3p" .. string.uchar(185),"Hans Christian Øersted",1825,1,3,"+III"}, {"Silicon","Si",14,28.0855,9,8.15168,1.90,1410,2355,2.33,"[Ne] 3s" .. string.uchar(178) .. " 3p" .. string.uchar(178),"Jöns Jacob Berzelius",1824,1,5,"+II, +IV, -IV"}, {"Phosphorus","P",15,30.973762,1,10.48669,2.19,44.1,280,1.823,"[Ne] 3s" .. string.uchar(178) .. " 3p" .. string.uchar(179),"Hennig Brand",1669,6,23,"+III, +V, -III"}, {"Sulfur","S",16,32.065,1,10.36001,2.58,112.8,444.6,1.96,"[Ne] 3s" .. string.uchar(178) .. " 3p" .. string.uchar(8308),"someone","ancient times",5,5,"+IV, +VI, -II"}, {"Chlorine","Cl",17,35.453,1,12.96763,3.16,-103,-34,0.003214,"[Ne] 3s" .. string.uchar(178) .. " 3p" .. string.uchar(178),"Carl Wilhelm Scheele",1774,5,4,"+I, +V, +VII, -I"}, {"Argon","Ar",18,39.948,4,15.759610,"no EN",-189.2,-185.7,1.784,"[Ne] 3s" .. string.uchar(178) .. " 3p" .. string.uchar(8310),"Sir William Ramsay and Lord Rayleigh",1894,1,6,"0"}, {"Potassium","K",19,39.0983,7,4.3406633,0.82,63.26,760,0.856,"[Ar] 4s" .. string.uchar(185),"Sir Humphry Davy",1807,2,5,"+I"}, {"Calcium","Ca",20,40.078,8,6.11316,1.0,842,1484,1.55,"[Ar] 4s" .. string.uchar(178),"Sir Humphrey Davy",1808,1,10,"+II"}, {"Scandium","Sc",21,44.955912,2,6.56149,1.36,1541,2836,2.985,"[Ar] 3d" .. string.uchar(185) .. " 4s" .. string.uchar(178),"Lars Fredrik Nilson",1879,4,7,"+III"}, {"Titanium","Ti",22,47.867,2,6.82812,1.54,1660,3287,4.507,"[Ar] 3d" .. string.uchar(185) .. " 4s" .. string.uchar(178),"William Gregor",1791,4,8,"+II, +III, +IV"}, {"Vanadium","V",23,50.9415,2,6.74619,1.63,1890,3380,6.11,"[Ar] 3d" .. string.uchar(179) .. " 4s" .. string.uchar(178),"Nils Gabriel Sefström",1830,2,5,"+II, +III, +IV, +V"}, {"Chromium","Cr",24,51.9961,2,6.76651,1.66,1890,2482,7.19,"[Ar] 3d" .. string.uchar(8309) .. " 4s" .. string.uchar(185),"Nicolas-Louis Vauquelin",1797,2,6,"+II, +III, +VI"}, {"Manganese","Mn",25,54.938044,2,7.43402,1.55,1246,2062,7.47,"[Ar] 3d" .. string.uchar(8309) .. " 4s" .. string.uchar(178),"Carl Wilhem Scheele",1774,2,7,"+II, +III, +IV, +VII"}, {"Iron","Fe",26,55.845,2,7.9024,1.83,1538,2861,7.874,"[Ar] 3d" .. string.uchar(8310) .. " 4s" .. string.uchar(178),"someone","ancient times",2,8,"+II, +III"}, {"Cobalt","Co",27,58.933195,2,7.88101,1.88,1495,2927,8.9,"[Ar] 3d" .. string.uchar(8311) .. " 4s" .. string.uchar(178),"George Brandt",1735,4,8,"+II, +III"}, {"Nickel","Ni",28,58.6934,2,7.6398,1.91,1453,2913,8.908,"[Ar] 3d" .. string.uchar(8312) .. " 4s" .. string.uchar(178),"Alex Fredrik Constedt",1751,1,10,"+II, +III"}, {"Copper","Cu",29,63.546,2,7.72638,1.90,1083,2567,8.96,"[Ar] 3d" .. string.uchar(185,8304) .. " 4s" .. string.uchar(185),"someone","ancient times",1,6,"+I, +II"}, {"Zinc","Zn",30,65.380,2,9.394199,1.65,420,907,7.14,"[Ar] 3d" .. string.uchar(185,8304) .. " 4s" .. string.uchar(178),"Andreas Marggraf",1746,4,10,"+II"}, {"Gallium","Ga",31,69.723,3,5.999301,1.81,29.78,2204,5.904,"[Ar] 3d" .. string.uchar(185,8304) .. " 4s" .. string.uchar(178) .. " 4p" .. string.uchar(185),"P.E. Lecoq de Boisbaudran",1875,7,6,"+III"}, {"Germanium","Ge",32,72.640,9,7.89943,2.01,937.4,2830,5.323,"[Ar] 3d" .. string.uchar(185,8304) .. " 4s" .. string.uchar(178) .. " 4p" .. string.uchar(178),"Clemens Winkler",1886,1,9,"+II, +IV"}, {"Arsenic","As",33,74.9216,9,9.7886,2.18,817,613,5.727,"[Ar] 3d" .. string.uchar(185,8304) .. " 4s" .. string.uchar(178) .. " 4p" .. string.uchar(179),"someone","ancient times",5,8,"+III, +V, -III"}, {"Selenium","Se",34,78.960,1,9.75239,2.55,217,684.9,4.819,"[Ar] 3d" .. string.uchar(185,8304) .. " 4s" .. string.uchar(178) .. " 4p" .. string.uchar(8308),"Jöns Jacob Berzelius",1817,4,9,"+IV, +VI, -II"}, {"Bromine","Br",35,79.904,1,11.8138,2.96,-7.2,58.78,3.12,"[Ar] 3d" .. string.uchar(185,8304) .. " 4s" .. string.uchar(178) .. " 4p" .. string.uchar(8309),"Antoine-Jérôme Balard",1826,3,10,"+I, +V, -I"}, {"Krypton","Kr",36,83.798,4,13.99961,"no EN",-156.6,-152.3,0.003708,"[Ar] 3d" .. string.uchar(185,8304) .. " 4s" .. string.uchar(178) .. " 4p" .. string.uchar(8310),"Sir William Ramsey and M.W. Travers",1898,1,15,"0"}, {"Rubidium","Rb",37,85.4678,7,4.177128,0.82,39,688,1.532,"[Kr] 5s" .. string.uchar(185),"Robert Bunsen and Gustav Kirchhoff",1861,2,11,"+I"}, {"Strontium","Sr",38,87.620,8,5.69485,0.95,769,1384,2.63,"[Kr] 5s" .. string.uchar(178),"Crawford and Cruikshank",1789,1,14,"+II"}, {"Yttrium","Y",39,88.90585,2,6.2173,1.22,1522,3345,4.472,"[Kr] 4d" .. string.uchar(185) .. " 5s" .. string.uchar(178),"Johann Gadolin",1794,4,10,"+III"}, {"Zirconium","Zr",40,91.224,2,6.63390,1.33,1852,4409,6.511,"[Kr] 4d" .. string.uchar(178) .. " 5s" .. string.uchar(178),"Martin Heinrich Klaproth",1789,4,11,"+IV"}, {"Niobium","Nb",41,92.90638,2,6.75885,1.6,2468,4744,8.57,"[Kr] 4d" .. string.uchar(8308) .. " 5s" .. string.uchar(185),"Chares Hatchett",1801,2,14,"+III, +V"}, {"Molybdenum","Mo",42,95.950,2,7.09243,2.16,2617,4612,10.28,"[Kr] 4d" .. string.uchar(8309) .. " 5s" .. string.uchar(185),"Carl Wilhelm Scheele",1778,2,11,"+VI"}, {"Technetium","Tc",43,98,2,7.28,1.9,2172,4877, 11.5,"[Kr] 4d" .. string.uchar(8310) .. " 5s" .. string.uchar(185),"Carlo Perrier",1937,4,9,"+IV, +VI, +VII"}, {"Ruthenium","Ru",44,101.07,2,7.36050,2.2,2334,4150,12.37,"[Kr] 4d" .. string.uchar(8311) .. " 5s" .. string.uchar(185),"Karl Karlovich Klaus",1844,4,11,"+III"}, {"Rhodium","Rh",45,102.9055,2,7.45890,2.28,1966,3695,12.45,"[Kr] 4d" .. string.uchar(8312) .. " 5s" .. string.uchar(185),"William Hyde Wollaston",1803,1,9,"+III"}, {"Palladium","Pd",46,106.42,2,8.3369,2.20,1554.9,2963,12.023,"[Kr] 4d" .. string.uchar(185,8304),"William Hyde Wollaston",1803,1,9,"+II, +IV"}, {"Silver","Ag",47,107.8682,2,7.57623,1.93,961.78,2162,10.49,"[Kr] 4d" .. string.uchar(185,8304) .. " 5s" .. string.uchar(185),"someone","ancient times",1,11,"+I"}, {"Cadmium","Cd",48,112.414,2,8.99382,1.69,320.9,765,8.65,"[Kr] 4d" .. string.uchar(185,8304) .. " 5s" .. string.uchar(178),"Fredrich Stromeyer",1817,4,15,"+II"}, {"Indium","In",49,114.818,3,5.78636,1.78,156.61,2080,7.31,"[Kr] 4d" .. string.uchar(185,8304) .. " 5s" .. string.uchar(178) .. " 5p" .. string.uchar(185),"Ferdinand Reich and H.T. Richter",1863,8,11,"+III"}, {"Tin","Sn",50,118.71,3,7.34392,1.96,231.97,2602,7.31,"[Kr] 4d" .. string.uchar(185,8304) .. " 5s" .. string.uchar(178) .. " 5p" .. string.uchar(178),"someone","ancient times",8,20,"+II, +IV"}, {"Antimony","Sb",51,121.76,9,8.60839,2.05,630.74,1587,6.697,"[Kr] 4d" .. string.uchar(185,8304) .. " 5s" .. string.uchar(178) .. " 5p" .. string.uchar(179),"someone","ancient times",4,12,"+III, +V, -III"}, {"Tellurium","Te",52,127.60,9,9.0096,2.1,449.8,989.9,6.24,"[Kr] 4d" .. string.uchar(185,8304) .. " 5s" .. string.uchar(178) .. " 5p" .. string.uchar(8308),"F.J. Müller von Reichenstein",1782,4,23,"+IV, +VI, -II"}, {"Iodine","I",53,126.90447,1,10.45126,2.66,113.5,184.35,4.94,"[Kr] 4d" .. string.uchar(185,8304) .. " 5s" .. string.uchar(178) .. " 5p" .. string.uchar(8309),"Bernard Courtois",1811,7,15,"+I, +V, +VII, -I"}, {"Xenon","Xe",54,131.293,4,12.12984,"no EN",-111.9,-108,0.00588,"[Kr] 4d" .. string.uchar(185,8304) .. " 5s" .. string.uchar(178) .. " 5p" .. string.uchar(8310),"S. W. Ramsey and M.W. Travers",1898,1,21,"0"}, {"Cesium","Cs",55,132.90545,7,3.893905,0.79,28.44,671,1.879,"[Xe] 6s" .. string.uchar(185),"Robert Bunse and Gustav Kirchhoff",1860,2,12,"+I"}, {"Barium","Ba",56,137.327,8,5.211664,0.89,727,1870,3.51,"[Xe] 6s" .. string.uchar(178),"Carl Scheele",1808,2,16,"+II"}, {"Lanthanum","La",57,138.90547,6,5.5769,1.10,918,3464,6.146,"[Xe] 5d" .. string.uchar(185) .. " 6s" .. string.uchar(178),"Carl Gustaf Monsander",1839,4,7,"+III"}, {"Cerium","Ce",58,140.116,6,5.5387,1.12,798,3443,6.689,"[Xe] 4f" .. string.uchar(185) .. " 5d" .. string.uchar(185) .. " 6s" .. string.uchar(178),"J.J. Berzelius and Wilhelm Hisinger",1803,4,9,"+III, +IV"}, {"Praseodymium","Pr",59,140.90765,6,5.473,1.13,931,3520,6.64,"[Xe] 4f" .. string.uchar(179) .. " 6s" .. string.uchar(178),"C.A. von Welsbach",1885,4,5,"+III"}, {"Neodymium","Nd",60,144.242,6,5.5250,1.14,1021,3074,7.01,"[Xe] 4f" .. string.uchar(185) .. " 6s" .. string.uchar(178),"Carl Auer von Welsbach",1885,4,9,"+III"}, {"Promethium","Pm",61,145,6,5.473,1.13,1042,3000,7.264,"[Xe] 4f" .. string.uchar(8309) .. " 6s" .. string.uchar(178),"J.A. Marinsky, L.E. Glendenin, and C.D. Coryell",1945,4,9,"+III"}, {"Samarium","Sm",62,150.36,6,5.6437,1.17,1074,1794,7.353,"[Xe] 4f" .. string.uchar(8310) .. " 6s" .. string.uchar(178),"Paul-Émile Lecoq de Boisbaudran",1879,4,11,"+II, +III"}, {"Europium","Eu",63,151.964,6,5.67038,1.2,822,1527,5.244,"[Xe] 4f" .. string.uchar(8311) .. " 6s" .. string.uchar(178),"Eugène-Anatole Demarçay",1901,4,35,"+II, +III"}, {"Gadolinium","Gd",64,157.25,6,6.14980,1.20,1313,3273,7.901,"[Xe] 4f" .. string.uchar(8311) .. " 5d" .. string.uchar(185) .. " 6s" .. string.uchar(178),"de Marignac and de Boisbaudran",1880,4,13,"+III"}, {"Terbium","Tb",65,158.92535,6,5.8938,1.2,1356,3230,8.219,"[Xe] 4f" .. string.uchar(8313) .. " 6s" .. string.uchar(178),"Carl Gustaf Mosander",1843,4,9,"+III, +IV"}, {"Dysprosium","Dy",66,162.5,6,5.9389,1.22,1412,2567,8.551,"[Xe] 4f" .. string.uchar(185,8304) .. " 6s" .. string.uchar(178),"Paul Emile Lecoq de Boisbaudran",1886,4,12,"+III"}, {"Holmium","Ho",67,164.93032,6,6.0215,1.23,1474,2700,8.795,"[Xe] 4f" .. string.uchar(185) .. " 6s" .. string.uchar(178),"Soret and Delafontaine",1878,4,4,"+III"}, {"Erbium","Er",68,167.259,6,6.1077,1.24,1529,2868,9.066,"[Xe] 4f" .. string.uchar(185,178) .. " 6s" .. string.uchar(178),"Carl Gustaf Mosander",1842,4,9,"+III"}, {"Thulium","Tm",69,168.93421,6,6.18431,1.25,1545,1950,9.32,"[Xe] 4f" .. string.uchar(185,179) .. " 6s" .. string.uchar(178),"Per Teodor Cleve",1879,4,5,"+III"}, {"Ytterbium","Yb",70,173.04,6,6.25416,1.1,819,1196,6.57,"[Xe] 4f" .. string.uchar(185,8308) .. " 6s" .. string.uchar(178),"Jean-Charles Galissard de Marignac",1878,1,9,"+II, +III"}, {"Lutetium","Lu",71,174.967,6,5.42586,1.27,1663,3402,9.841,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(185) .. " 6s" .. string.uchar(178),"George Urbain",1907,4,9,"+III"}, {"Hafnium","Hf",72,178.49,2,6.82507,1.3,2227,4603,13.31,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(178) .. " 6s" .. string.uchar(178),"Dirk Coster and G.C. von Hevesy",1923,4,10,"+IV"}, {"Tantalum","Ta",73,180.94788,2,7.54957,1.5,2996,5425,16.65,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(179) .. " 6s" .. string.uchar(178),"Anders Gustaf Ekeberg", 1802,2,4,"+V"}, {"Tungsten","W",74,183.84,2,7.86403,2.36,3410,5660,19.25,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(8308) .. " 6s" .. string.uchar(178),"Fausto and Juan José Elhuyar",1783,2,10,"+III"}, {"Rhenium","Re",75,186.207,2,7.83352,1.9,3180,5627,21.02,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(8309) .. " 6s" .. string.uchar(178),"Ida and Walter Noddack and Berg",1925,4,9,"+IV, +VI, +VII"}, {"Osmium","Os",76,190.23,2,8.43823,2.2,3033,5012,22.59,"[Xe] 4f" .. string.uchar(185,8308) .. " 6s" .. string.uchar(178),"Smithson Tennant",1804,4,13,"+III, +IV"}, {"Iridium","Ir",77,192.217,2,8.96702,2.20,2410,4130,22.56,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(8311) .. " 6s" .. string.uchar(178),"Smithson Tennant",1803,1,11,"+III, +IV"}, {"Platinum","Pt",78,195.084,2,8.9588,2.28,1769,3827,21.45,"[Xe] 4f" .. string.uchar(185,8304) .. " 5d" .. string.uchar(8313) .. " 6s" .. string.uchar(185),"Julius Caesar Scaliger",1557,1,13,"+II, +IV"}, {"Gold","Au",79,196.96657,2,9.22553,2.54,1064.3,2808,19.3,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(185,8304) .. " 6s" .. string.uchar(185),"someone","ancient times",1,7,"+I, +III"}, {"Mercury","Hg",80,200.59,2,10.4375,2.00,-38.87,356.58,13.534,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(185,8304) .. " 6s" .. string.uchar(178),"someone","ancient times",5,12,"+I, +II"}, {"Thallium","Tl",81,204.3833,3,3.108194,1.62,303.5,1457,11.85,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(185,8304) .. " 6s" .. string.uchar(178) .. " 6p" .. string.uchar(185),"Sir William Crookes",1861,7,11,"+I, +III"}, {"Lead","Pb",82,207.20,3,7.41663,2.33,327.5,1740,11.34,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(185,8304) .. " 6s" .. string.uchar(178) .. " 6p" .. string.uchar(178),"someone","ancient times",1,13,"+II, +IV"}, {"Bismuth","Bi",83,208.9804,3,7.2855,2.02,271.3,1560,9.78,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(185,8304) .. " 6s" .. string.uchar(178) .. " 6p" .. string.uchar(179),"someone","ancient times",6,14,"+III, +V"}, {"Polonium","Po",84,209,3,8.414,2.0,254,962,9.196,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(185,8304) .. " 6s" .. string.uchar(178) .. " 6p" .. string.uchar(8308),"Pierre and Marie Curie",1898,6,12,"+II, +IV"}, {"Astatine","At",85,210,1,9.5,2.2,302,337,"unknown","[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(185,8304) .. " 6s" .. string.uchar(178) .. " 6p" .. string.uchar(8309),"Dale R. Corson",1940,"unknown",7,"unknown"}, {"Radon","Rn",86,222,4,10.7485,"no EN",-71,-61.8,0.00973,"[Xe] 4f" .. string.uchar(185,8308) .. " 5d" .. string.uchar(185,8304) .. " 6s" .. string.uchar(178) .. " 6p" .. string.uchar(8310),"Fredrich Ernst Dorn",1900,1,7,"0"}, {"Francium","Fr",87,223,7,4.072741,0.7,27,677,"unknown","[Rn] 7s" .. string.uchar(185),"Marguerite Perey",1939,2,4,"+I"}, {"Radium","Ra",88,226,8,5.278423,0.9,700,1737,5,"[Rn] 7s" .. string.uchar(178),"Pierre and Marie Curie",1898,2,6,"+II"}, {"Actinium","Ac",89,227,5,5.17,1.1,1050,3200,10.07,"[Rn] 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"André-Louis Debierne",1899,1,4,"+III"}, {"Thorium","Th",90,232.03806,5,6.3067,1.3,1750,4790,11.724,"[Rn] 6d" .. string.uchar(178) .. " 7s" .. string.uchar(178),"Jöns Jacob Berzelius",1828,1,9,"+IV"}, {"Protactinium","Pa",91,231.03588,5,5.89,1.5,1568,"unknown",15.37,"[Rn] 5f" .. string.uchar(178) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"K. Fajans and O.H. Göhring",1913,7,5,"+IV, +V"}, {"Uranium","U",92,238.02891,5,6.1941,1.38,1132,3818,19.05,"[Rn] 5f" .. string.uchar(179) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"Martin Heinrich Klaproth",1789,3,11,"+III, +IV, +V, +VI"}, {"Neptunium","Np",93,237.0482,5,6.2657,1.36,640,3902,20.45,"[Rn] 5f" .. string.uchar(8308) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"E.M. McMillan and P.H. Abelson",1940,8,8,"+III, +IV, +V, +VI"}, {"Plutonium","Pu",94,244,5,6.0260,1.28,639.5,3235,19.816,"[Rn] 5f" .. string.uchar(8310) .. " 7s" .. string.uchar(178),"G.T. Seaborg, J.W. Kennedy, and A.C. Wahl",1941,6,11,"+III, +IV, +V, +VI"}, {"Americium","Am",95,243,5,5.9738,1.3,994,2607,13.67,"[Rn] 5f" .. string.uchar(8311) .. "7s" .. string.uchar(178)," Seaborg, James, Morgan, and Ghiorso",1944,4,8,"+III, +IV, +V, +VI"}, {"Curium","Cm",96,247,5,5.9914,1.3,1340,3110,13.51,"[Rn],5f" .. string.uchar(8313) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"G.T. Seaborg, R.A. James, and Albert Ghiorso",1944,"unknown",10,"+III, +IV"}, {"Berkelium","Bk",97,247,5,6.1979,1.3,1050,"unknown",14.78,"[Rn] 5f" .. string.uchar(8313) .. " 6d" .. string.uchar(8304) .. " 7s" .. string.uchar(178),"Thompson, Ghiorso, and Seaborg",1949,"unknown",8,"+III, +IV"}, {"Californium","Cf",98,251,5,6.2817,1.3,900,"unknown",15.1,"[Rn] 5f" .. string.uchar(8313) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(185),"Thompson, Street Jr., Ghiorso, and Seaborg",1950,"unknown",10,"+III"}, {"Einsteinium","Es",99,252,5,6.42,1.3,860,"unknown","unknown","[Rn] 5f" .. string.uchar(185,8304) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"Albert Ghiorso",1952,"unknown",10,"unknown"}, {"Fermium","Fm",100,257,5,6.50,1.3,1527,"unknown","unknown","[Rn] 5f" .. string.uchar(185) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"Albert Ghiorso",1952,"unknown",1,"unknown"}, {"Mendelevium","Md",101,258,5,6.58,1.3,827,"unknown","unknown","[Rn] 5f" .. string.uchar(185,178) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"Ghiorso, Harvey, Choppin, Thompson, and Seaborg",1955,"unknown",1,"unknown"}, {"Nobelium","No",102,259,5,6.62621,1.3,827,"unknown","unknown","[Rn] 5f" .. string.uchar(185,179) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"Nobel Institute for Physics",1957,"unknown",1,"unknown"}, {"Lawrencium","Lr",103,262,5,4.96,1.3,1627,"unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(185) .. " 7s" .. string.uchar(178),"Ghiorso, Sikkeland, Larsh, and Latimer ",1961,"unknown",1,"unknown"}, {"Rutherfordium","Rf",104,267,2,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(178) .. " 7s" .. string.uchar(178),"JINR Dubna",1964,"unknown",9,"unknown"}, {"Dubnium","Db",105,262,2,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(179) .. " 7s" .. string.uchar(178),"Paul-Émile Lecoq de Boisbaudran",1886,"unknown",1,"unknown"}, {"Seaborgium","Sg",106,269,2,"unknown","unknown","unknown","unknown","unknown","[Rn] 7s" .. string.uchar(178) .. " 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(8308),"Albert Ghiorso and Lawrence Laboratory",1974,"unknown",1,"unknown"}, {"Bohrium","Bh",107,264,2,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(8309) .. " 7s" .. string.uchar(178),"JINR Dubna",1976,"unknown",3,"unknown"}, {"Hassium","Hs",108,269,2,"unknown","unknown","unknown","unknown","unknown","[Rn]7s" .. string.uchar(178) .. " 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(8310),"Institute for Heavy Ion Research",1984,"unknown",1,"unknown"}, {"Meitnerium","Mt",109,278,10,"unknown","unknown","unknown","unknown","unknown","[Rn] 7s" .. string.uchar(178) .. " 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(8311),"Institute for Heavy Ion Research",1982,"unknown",1,"unknown"}, {"Darmstadtium","Ds",110,281,10,"unknown","unknown","unknown","unknown","unknown","[Rn] 7s" .. string.uchar(178) .. " 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(8312),"Institute for Heavy Ion Research",1995,"unknown",1,"unknown"}, {"Roentgenium","Rg",111,272,10,"unknown","unknown","unknown","unknown","unknown","[Rn]7s" .. string.uchar(178) .. " 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(8313),"Institute for Heavy Ion Research",1994,"unknown",1,"unknown"}, {"Copernicium","Cn",112,277,10,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(185,8304) .. " 7s" .. string.uchar(178),"Institute for Heavy Ion Research",1996,"unknown",1,"unknown"}, {"Nihonium","Nh",113,286,10,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(185,8304) .. " 7s" .. string.uchar(178) .. " 7p" .. string.uchar(185),"RIKEN Nishina Center",2004,"unknown","unknown","unknown"}, {"Flerovium","Fl",114,289,10,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(185,8304) .. " 7s" .. string.uchar(178) .. " 7p" .. string.uchar(178),"JINR Dubna",1999,"unknown","unknown","unknown"}, {"Moscovium","Mc",115,289,10,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(185,8304) .. " 7s" .. string.uchar(178) .. " 7p" .. string.uchar(179),"JINR Dubna and LLNL California",2010,"unknown","unknown","+IV"}, {"Livermorium","Lv",116,293,10,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(185,8304) .. " 7s" .. string.uchar(178) .. " 7p" .. string.uchar(8308),"JINR Dubna and LLNL California",2000,"unknown",1,"unknown"}, {"Tennessine","Ts",117,294,10,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(185,8304) .. " 7s" .. string.uchar(178) .. " 7p" .. string.uchar(8309),"JINR Dubna",2010,"unknown","unknown","unknown"}, {"Oganesson","Og",118,294,10,"unknown","unknown","unknown","unknown","unknown","[Rn] 5f" .. string.uchar(185,8308) .. " 6d" .. string.uchar(185,8304) .. " 7s" .. string.uchar(178) .. " 7p" .. string.uchar(8310),"JINR Dubna",2006,"unknown",1,"unknown"} } pse_order = { {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}, {3,4,0,0,0,0,0,0,0,0,0,0,5,6,7,8,9,10}, {11,12,0,0,0,0,0,0,0,0,0,0,13,14,15,16,17,18}, {19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36}, {37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54}, {55,56,0,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86}, {87,88,0,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71}, {0,0,0,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103} } pse_link = {} precise_match = nil layout = "title" query = "" elsel = 0 name = pse_db[1][2] num = pse_db[1][3] mass = pse_db[1][4] en = pse_db[1][7] color = pse_db[1][5] border = false if platform.isColorDisplay() then color_bg = {{217,248,254},{243,232,252},{215,249,232},{254,231,235},{254,230,213},{224,243,254},{217,248,254},{254,231,231},{254,247,225},{231,231,234},{191,191,191}} -- nonmetal=1/transition metal=2/semimetal=3/noble gas=4/actinide=5/lanthanide=6/alkali metals=7/alkaline earth metals=8/metalloid=9/unknown=10/filtered out=11 color_text = {{0, 0, 0}, {70, 70, 70}} else color_bg = {{170,170,170},{255,255,255},{255,255,255},{130,130,130},{255,255,255},{255,255,255},{255,255,255},{255,255,255},{255,255,255},{191,191,191}} color_text = {{0, 0, 0}, {180, 180, 180}} end pse_types = {"Nonmetal","Trans. metal","P.Trans. metal","Noble gas","Actinide","Lanthanide","Alkali Metal","A. E. Metal","Metalloid","Unknown"} types = {"Nonmetal","Transition metal","Post-Transition metal","Noble gas","Actinide","Lanthanide","Alkali Metal","Alkaline Earth Metal","Metalloid","Unknown"} pse_groups = {{"Ia",0.5,1},{"IIa",1.5,2},{"IIIb",3.5,3},{"IVb",3.5,4},{"Vb",3.5,5},{"VIb",3.5,6},{"VIIb",3.5,7},{"VIIIb",3.5,9},{"Ib",3.5,11},{"IIb",3.5,12},{"IIIa",1.5,13},{"IVa",1.5,14},{"Va",1.5,15},{"VIa",1.5,16},{"VIIa",1.5,17},{"VIIIa",0.5,18}} structures = {"Cubic, body centered","Cubic, face centered","Cubic","Hexagonal","Rhombohedral","Monoclinic","Tetragonal","Orthorhombic"} cubeVertices={} translate(cubeVertices,0,0,-3) scale(cubeVertices,0.8,0.8,0.8) --Lua Tiny3D - By Loic Pujet interval = 0.05 --timer.start(interval) nrofcubes = 1 cubedata = {{0,0,0,0,0,0}} setcube = true rowcel = 0 rowsel = 0 colsel = 0 on.resize(platform.window:width(),platform.window:height()) end function on.resize(x,y) XRatio = x/320 YRatio = y/212 end --------------- -----PAINT----- --------------- function on.paint(gc) if layout=="pse" then precise_match = nil gc:setColorRGB(0,0,0) gc:setFont("sansserif","r","6") for i=1,7 do gc:drawString(i,(1)*XRatio,(i*20-8)*YRatio,"top") end for i=1,16 do gc:drawString(pse_groups[i][1],(pse_groups[i][3]*17-9)*XRatio,(pse_groups[i][2]*20-10)*YRatio,"top") end for i=1,#pse_order do for j=1,#pse_order[i] do if pse_order[i][j]~=0 then local matches = elementMatchesQuery(pse_db[pse_order[i][j]]) if matches then gc:setColorRGB(unpack(color_bg[pse_db[pse_order[i][j]][5]])) else gc:setColorRGB(unpack(color_bg[11])) end gc:fillRect((j*17-8)*XRatio,(i*20-10)*YRatio,(16)*XRatio,(19)*YRatio) if matches then gc:setColorRGB(unpack(color_text[1])) else gc:setColorRGB(unpack(color_text[2])) end gc:drawString(pse_db[pse_order[i][j]][2],(j*17-8)*XRatio,(i*20-4)*YRatio,"top") gc:drawString(pse_db[pse_order[i][j]][3],(j*17-7)*XRatio,(i*20-12)*YRatio,"top") if #pse_link ~= #pse_db then table.insert(pse_link,{(j*17-9)*XRatio,(i*20-10)*YRatio,17*XRatio,19*YRatio,pse_order[i][j],i,j}) end if matches == 2 then precise_match = pse_order[i][j] end end end end table.sort(pse_link,function (a,b) return (a[5]83 or pse_db[elsel][3]==43 or pse_db[elsel][3]==61 then gc:setFont("sansserif","b","10") local w = gc:getStringWidth("Name: "..pse_db[elsel][1].." ( "..pse_db[elsel][2].." )") gc:drawImage(radioactive,w+5,5) end gc:setColorRGB(190,190,190) gc:fillPolygon({259,5, 262,5, 262,8, 265,8, 265,14, 295,14, 295,8, 310,8, 310,5, 313,5, 313,26, 268,26, 268,19, 265,19, 265,26, 259,26}) gc:fillPolygon({268,29, 313,29, 313,35, 268,35}) gc:setColorRGB(0,0,0) gc:fillPolygon({colsel*3+256,rowsel*3+2, colsel*3+256+3,rowsel*3+2, colsel*3+259,rowsel*3+5, colsel*3+256,rowsel*3+5}) gc:setFont("sansserif","b","10") gc:drawString("Name: "..pse_db[elsel][1].." ( "..pse_db[elsel][2].." )",(1)*XRatio,(0)*YRatio,"top") gc:setFont("sansserif","r","8") gc:drawString("Atomic Number: "..pse_db[elsel][3],(1)*XRatio,(15)*YRatio,"top") gc:drawString("Relative Atomic Mass (C" .. string.uchar(185,178) .. "): "..pse_db[elsel][4],(1)*XRatio,(25)*YRatio,"top") gc:drawString("Type: "..types[pse_db[elsel][5]],(1)*XRatio,(35)*YRatio,"top") if pse_db[elsel][6] ~= "unknown" then gc:drawString("Ionisation Energy: "..pse_db[elsel][6] .. " eV",(1)*XRatio,(45)*YRatio,"top") else gc:drawString("Ionisation Energy: "..pse_db[elsel][6],(1)*XRatio,(45)*YRatio,"top") end gc:drawString("Electronegativity (Pauling): "..pse_db[elsel][7],(1)*XRatio,(55)*YRatio,"top") if pse_db[elsel][8] ~= "unknown" then gc:drawString("Melting Point: "..(pse_db[elsel][8]+273.15).." K ="..(pse_db[elsel][8]).." " .. string.uchar(176) .. "C ="..(pse_db[elsel][8]*1.8+32).." " .. string.uchar(176) .. "F",(1)*XRatio,(65)*YRatio,"top") else gc:drawString("Melting Point: "..pse_db[elsel][8],(1)*XRatio,(65)*YRatio,"top") end if pse_db[elsel][9] ~= "unknown" then gc:drawString("Boiling Point: "..(pse_db[elsel][9]+273.15).." K ="..(pse_db[elsel][9]).." " .. string.uchar(176) .. "C "..(pse_db[elsel][9]*1.8+32).." =" .. string.uchar(176) .. "F",(1)*XRatio,(75)*YRatio,"top") else gc:drawString("Boiling Point: "..pse_db[elsel][9],(1)*XRatio,(75)*YRatio,"top") end if pse_db[elsel][10] ~= "unknown" then gc:drawString("Density at 20" .. string.uchar(176) .. "C: "..pse_db[elsel][10].." g" .. string.uchar(247) .. "cm" .. string.uchar(179),(1)*XRatio,(85)*YRatio,"top") else gc:drawString("Density at 20" .. string.uchar(176) .. "C: "..pse_db[elsel][10],(1)*XRatio,(85)*YRatio,"top") end gc:drawString("Electron Configuration: "..pse_db[elsel][11],(1)*XRatio,(95)*YRatio,"top") gc:drawString("Discovered by "..pse_db[elsel][12].." in "..pse_db[elsel][13],(1)*XRatio,(105)*YRatio,"top") gc:drawString("Nr of Natural Isotopes: "..pse_db[elsel][15],(1)*XRatio,(115)*YRatio,"top") gc:drawString("Oxidation States: "..pse_db[elsel][16],(1)*XRatio,(125)*YRatio,"top") if pse_db[elsel][14] ~= "unknown" and pse_db[elsel][14]>0 then gc:drawString("Crystal Structure: "..structures[pse_db[elsel][14]],(1)*XRatio,(135)*YRatio,"top") else gc:drawString("Crystal Structure: "..pse_db[elsel][14],(1)*XRatio,(135)*YRatio,"top") end if rowsel > 8 then rowcel = rowsel - 3 else rowcel = rowsel end gc:drawString("Group: "..colsel,(259)*XRatio,(35)*YRatio,"top") gc:drawString("Period: "..rowcel,(259)*XRatio,(45)*YRatio,"top") gc:setFont("sansserif","b",10) if elsel < 118 then gc:setColorRGB(unpack(color_bg[pse_db[elsel+1][5]])) gc:drawString(pse_db[elsel+1][2] .. " " .. string.uchar(187),290*XRatio,160*YRatio,"top") end if elsel > 1 then gc:setColorRGB(unpack(color_bg[pse_db[elsel-1][5]])) gc:drawString(string.uchar(171) .. " " .. pse_db[elsel-1][2],2*XRatio,160*YRatio,"top") end if pse_db[elsel][14]==2 then if setcube then cubeVertices={{-1,-1,-1},{1,-1,-1},{-1,1,-1},{-1,-1,1},{1,1,-1},{-1,1,1},{1,-1,1},{1,1,1},{0,0,-1},{0,0,1},{0,-1,0},{0,1,0},{1,0,0},{-1,0,0}} cubeFaces={{1,2,5,3},{1,4,6,3},{1,4,7,2},{8,7,4,6},{8,5,3,6},{8,5,2,7}} translate(cubeVertices,0,0,-3) scale(cubeVertices,0.8,0.8,0.8) setcube = false end render(gc,cubeVertices,cubeFaces,2,{200,0,0},8) elseif pse_db[elsel][14]==1 then if setcube then cubeVertices={{-1,-1,-1},{1,-1,-1},{-1,1,-1},{-1,-1,1},{1,1,-1},{-1,1,1},{1,-1,1},{1,1,1},{0,0,0}} cubeFaces={{1,2,5,3},{1,4,6,3},{1,4,7,2},{8,7,4,6},{8,5,3,6},{8,5,2,7}} translate(cubeVertices,0,0,-3) scale(cubeVertices,0.8,0.8,0.8) setcube = false end render(gc,cubeVertices,cubeFaces,2,{200,0,0},8) elseif pse_db[elsel][14]==3 then if setcube then cubeVertices={{-1,-1,-1},{1,-1,-1},{-1,1,-1},{-1,-1,1},{1,1,-1},{-1,1,1},{1,-1,1},{1,1,1}} cubeFaces={{1,2,5,3},{1,4,6,3},{1,4,7,2},{8,7,4,6},{8,5,3,6},{8,5,2,7}} translate(cubeVertices,0,0,-3) scale(cubeVertices,0.8,0.8,0.8) setcube = false end render(gc,cubeVertices,cubeFaces,2,{200,0,0},8) elseif pse_db[elsel][14]==5 then if setcube then cubeVertices={{-0.1,-1,1},{-0.1,1,1},{1.9,1,1},{1.9,-1,1},{-1,-1,-1},{-1,1,-1},{1,1,-1},{1,-1,-1}} cubeFaces={{1,2,3,4},{5,6,7,8},{1,2,6,5},{3,4,8,7}} translate(cubeVertices,0,0,-3) scale(cubeVertices,0.8,0.8,0.8) setcube = false end render(gc,cubeVertices,cubeFaces,2,{200,0,0},8) elseif pse_db[elsel][14]==4 then if setcube then cubeVertices={{0,-1,1},{-0.6,-0.6,1},{-0.6,0.6,1},{0,1,1},{0.6,0.6,1},{0.6,-0.6,1},{0,-1,-1},{-0.6,-0.6,-1},{-0.6,0.6,-1},{0,1,-1},{0.6,0.6,-1},{0.6,-0.6,-1}} cubeFaces={{1,2,3,4,5,6},{7,8,9,10,11,12},{1,2,8,7},{3,4,10,9},{5,6,12,11}} translate(cubeVertices,0,0,-3) scale(cubeVertices,0.8,0.8,0.8) setcube = false end render(gc,cubeVertices,cubeFaces,2,{200,0,0},8) elseif pse_db[elsel][14]==6 then if setcube then cubeVertices={{-0.3,-1,1},{-0.3,1,1},{1.1,1,1},{1.1,-1,1},{-0.5,-1,-1},{-0.5,1,-1},{0.7,1,-1},{0.7,-1,-1}} cubeFaces={{1,2,3,4},{5,6,7,8},{1,2,6,5},{3,4,8,7}} translate(cubeVertices,0,0,-3) scale(cubeVertices,0.8,0.8,0.8) setcube = false end render(gc,cubeVertices,cubeFaces,2,{200,0,0},8) elseif pse_db[elsel][14]==7 then if setcube then cubeVertices={{-1,-1,0},{-1,1,0},{1,1,0},{1,-1,0},{0,0,1.5},{0,0,-1.5}} cubeFaces={{1,2,3,4},{1,2,5},{1,2,6},{3,4,5},{3,4,6}} translate(cubeVertices,0,0,-3) scale(cubeVertices,0.8,0.8,0.8) setcube = false end render(gc,cubeVertices,cubeFaces,2,{200,0,0},8) elseif pse_db[elsel][14]==8 then if setcube then cubeVertices={{-1,-0.5,-1},{1,-0.5,-1},{-1,0.5,-1},{-1,-0.5,1},{1,0.5,-1},{-1,0.5,1},{1,-0.5,1},{1,0.5,1}} cubeFaces={{1,2,5,3},{1,4,6,3},{1,4,7,2},{8,7,4,6},{8,5,3,6},{8,5,2,7}} translate(cubeVertices,0,0,-3) scale(cubeVertices,0.8,0.8,0.8) setcube = false end render(gc,cubeVertices,cubeFaces,2,{200,0,0},8) end -- End drawing fct specs elseif layout == "title" then gc:setFont("serif","b",15) gc:setColorRGB(29, 105, 167) gc:drawString("TI-Periodic 2.0",(platform.window:width()-gc:getStringWidth("TI-Periodic 2.0"))/2,(platform.window:height()-gc:getStringHeight("TI-Periodic 2.0"))/4,"top") gc:setFont("sansserif","r",10) gc:setColorRGB(0,0,0) gc:drawString("Created By:", (platform.window:width()-gc:getStringWidth("Created By:"))/2,70,"top") gc:setFont("sansserif","r",6) gc:drawString("Nick Steen - Original Code", (platform.window:width()-gc:getStringWidth("Nick Steen - Original Code"))/2,90,"top") gc:drawString("popoffka - Search Function", (platform.window:width()-gc:getStringWidth("popoffka - Search Function"))/2,100,"top") gc:drawString("SophisticatedFox - Revision & Updates", (platform.window:width()-gc:getStringWidth("SophisticatedFox - Revision & Updates"))/2,110,"top") gc:setFont("serif","r",9) gc:drawString("Press the help button (ctrl + trig) for help, or enter to load.",(platform.window:width()-gc:getStringWidth("Press the help button (ctrl + trig) for help, or enter to load."))/2,140,"top") end end --------------- -----TIMER----- --------------- function on.timer() rotate(cubeVertices,math.pi/80,0,0,1) platform.window:invalidate(XRatio*100,YRatio*130,XRatio*120,YRatio*90) end ---------------- ------HELP------ ---------------- function on.help() layout = "help" info = D2Editor.newRichText() info:move(0,0) info:resize(platform.window:width(),platform.window:height()) info:setFontSize(6) local prompt = "b:Using b:the b:TI-Periodic b:Table \n 1. Searching for an Element \n There are several ways to search for an element in the TI-Periodic table: \n - By Atomic Number: If you know the atomic number of the element you are interested in, simply enter the number using the keypad and the calculator will highlight the corresponding element on the periodic table. \n - By Element Name: You can also search for an element by typing its name. Use the keypad to enter the first few letters of the element's name, and the calculator will narrow down the options for you. \n - By Clicking on the Element: Alternatively, you can navigate directly to an element by clicking on it in the periodic table displayed on the calculator's screen. \n b:2. b:Navigating b:Between b:Elements \n To explore information about other elements without returning to the main periodic table screen, you can use the left and right arrow keys on your calculator: \n - Left Arrow: View the previous element in the periodic table. \n - Right Arrow: View the next element in the periodic table." prompt = prompt:gsub("b:","\\1keyword ") info:setExpression(prompt) info:setReadOnly() platform.window:invalidate() end ----------------------- -----KEYBOARD INPUT---- ----------------------- function on.charIn(char) if #query == 3 then return end query = query .. char platform.window:invalidate() end function on.backspaceKey() query = string.sub(query, 1, -2) platform.window:invalidate() end function on.enterKey() if layout == "pse" then if precise_match ~= nil then for i=1,#pse_link do if elementMatchesQuery(pse_db[pse_link[i][5]]) then rowsel = pse_link[i][6] colsel = pse_link[i][7] if rowsel > 8 then rowcel = rowsel - 3 else rowcel = rowsel end end end elsel = precise_match layout = "specs" query = "" cursor.set("pointer") timer.start(interval) end elseif layout == "title" then layout = "pse" end platform.window:invalidate() end function on.escapeKey() if layout=="specs" then layout="pse" timer.stop() setcube = true elseif layout=="help" then layout="pse" info:setVisible(false) else query = "" end cursor.show("pointer") platform.window:invalidate() end function elementMatchesQuery(el) -- this returns one of: nil, 1, 2 -- nil means there's no match, 1 means a fuzzy match, -- 2 means a precise match -- all elements are fine if there's no query at all if query == "" then return 1 end -- if the query's a number, match the element with this Z if tonumber(query) ~= nil then if el[3] == tonumber(query) then return 2 else return nil end end -- if the query's a string, match all elements whose symbols -- start with that string if string.upper(el[2]) == string.upper(query) then return 2 elseif string.upper(string.sub(el[2], 1, #query)) == string.upper(query) then return 1 end return nil end ----------------------- -----MOUSE ACTIONS----- ----------------------- function on.mouseMove(x,y) if layout=="pse" then elsel = 0 cursor.set("pointer") if #pse_link>0 and #pse_order>0 then for i=1,#pse_link do if x>pse_link[i][1] and y>pse_link[i][2] and x<(pse_link[i][3]+pse_link[i][1]) and y<(pse_link[i][4]+pse_link[i][2]) and elementMatchesQuery(pse_db[pse_link[i][5]]) then cursor.set("hand pointer") elsel = pse_link[i][5] color = pse_db[elsel][5] name = pse_db[elsel][2] num = pse_db[elsel][3] mass = pse_db[elsel][4] en = pse_db[elsel][7] rowsel = pse_link[i][6] colsel = pse_link[i][7] if rowsel > 8 then rowcel = rowsel - 3 else rowcel = rowsel end end end end end platform.window:invalidate() end function on.mouseDown(x,y) if elsel~=0 then layout = "specs" query = "" cursor.set("pointer") timer.start(interval) if layout~="specs" then setcube = true end end platform.window:invalidate() end ----------------------- -----ARROW ACTIONS----- ----------------------- function on.arrowLeft() if layout == "specs" then if elsel ~= 1 and elsel ~= 0 then elsel = elsel - 1 rowsel = pse_link[elsel][6] colsel = pse_link[elsel][7] if rowsel > 8 then rowcel = rowsel - 3 else rowcel = rowsel end end timer.start(interval) setcube = true end platform.window:invalidate() end function on.arrowRight() if layout == "specs" then if elsel ~= 118 and elsel ~= 0 then elsel = elsel + 1 rowsel = pse_link[elsel][6] colsel = pse_link[elsel][7] if rowsel > 8 then rowcel = rowsel - 3 else rowcel = rowsel end end timer.start(interval) setcube = true end platform.window:invalidate() end ---------------- -----IMAGES----- ---------------- radioactive = image.new(_R.IMG.radioactive) radioactive = image.copy(radioactive,12,12) ------------------------------- -----TINY 3D BY LOIC PUJET----- ------------------------------- function multiplyMatrix(matrix,vector) local x = matrix[1][1]*vector[1]+matrix[1][2]*vector[2]+matrix[1][3]*vector[3] local y = matrix[2][1]*vector[1]+matrix[2][2]*vector[2]+matrix[2][3]*vector[3] local z = matrix[3][1]*vector[1]+matrix[3][2]*vector[2]+matrix[3][3]*vector[3] return x,y,z end function rotate(vertices,angle,x,y,z) local sum = x+y+z x,y,z = x/sum,y/sum,z/sum local c,s = math.cos(angle),math.sin(angle) local matrix = {{x*x+(1-x*x)*c,x*y*(1-c)-z*s,x*z*(1-c)+y*s},{x*y*(1-c)+z*s,y*y+(1-y*y)*c,y*z*(1-c)-x*s},{x*z*(1-c)-y*s,y*z*(1-c)+x*s,z*z+(1-z*z)*c}} for i,e in pairs(vertices) do vertices[i] = {multiplyMatrix(matrix,e)} end end function translate(vertices,x,y,z) for i,e in pairs(vertices) do vertices[i] = {e[1]+x,e[2]+y,e[3]+z} end end function scale(vertices,x,y,z) for i,e in pairs(vertices) do vertices[i] = {e[1]*x,e[2]*y,e[3]*z} end end function width() return platform.window:width() end function height() return platform.window:height() end function reverseTable(tbl) local tbl2 = {} for i,e in ipairs(tbl) do tbl2[#tbl-i+1] = e end return tbl2 end function replaceFaces(tbl1,tbl2,faces) local faces2 = {} for i,e in pairs(tbl1) do for j,e2 in pairs(tbl2) do if e2 then if e == e2 then table.insert(faces2,faces[j]) tbl2[j] = nil end end end end return reverseTable(faces2) end function sortFaces(vertices,faces) local faces2,distTbl,facesTbl={},{},{} local middle = {} local dist,xsum,ysum,zsum = 0,0,0,0 for i,e in pairs(faces) do xsum,ysum,zsum = 0,0,0,0 for j,e2 in pairs(e) do xsum,ysum,zsum = xsum+vertices[e2][1],ysum+vertices[e2][2],zsum+vertices[e2][3] end middle = {xsum/#e,ysum/#e+5,zsum/#e} dist = math.sqrt(middle[1]*middle[1]+middle[2]*middle[2]+middle[3]*middle[3]) table.insert(distTbl,dist) table.insert(facesTbl,dist) end table.sort(distTbl) return replaceFaces(distTbl,facesTbl,faces) end function renderFaces(gc,vertices,faces,pos,mode,color) local polygon = {} local faces2 = sortFaces(vertices,faces) for i,e in pairs(faces2) do polygon = {} drawPoly = true for j,f in pairs(faces2[i]) do if not pos[f] then drawPoly = false else table.insert(polygon,pos[f][1]) table.insert(polygon,pos[f][2]) end end if drawPoly then table.insert(polygon,pos[faces2[i][1]][1]) table.insert(polygon,pos[faces2[i][1]][2]) if mode == 4 or mode == 5 then gc:setColorRGB(color[1],color[2],color[3]) gc:fillPolygon(polygon) end if mode == 2 or mode == 3 or mode == 4 then gc:setColorRGB(0,0,0) gc:drawPolyLine(polygon) end end end end function renderVertices(gc,pos) gc:setColorRGB(0,0,0) for i,e in pairs(pos) do if e then gc:fillRect(e[1]-1,e[2]-1,3,3) end end end function render(gc,vertices,faces,mode,color) local yDist,pos = 0,{} for i,e in pairs(vertices) do if e[2]>-5 then yDist = 5/(e[2]+5) table.insert(pos,{e[1]*yDist*25+width()/2,height()/2-e[3]*yDist*25}) else table.insert(pos,false) end end if mode == 1 or mode == 2 then renderVertices(gc,pos) end if mode == 2 or mode == 3 or mode == 4 or mode == 5 then renderFaces(gc,vertices,faces,pos,mode,color) end end