Anyone need a Lua version of the periodic table?

Hey guys, I while ago I remade the periodic table in Lua and now I’m giving it out because I don’t really need it anymore and it took a long time for me to makes so I thought I could save someone some time.

Sorted by Atomic Number

{Atomic Number, Symbol, Name, Atomic Mass}

{{1,'H','Hydrogen',1.00794},{2,'He','Helium',4.003},{3,'Li','Lithium',6.941},{4,'Be','Beryllium',9.012182},{5,'B','Boron',10.811},{6,'C','Carbon',12.0107},{7,'N','Nitrogen',14.00674},{8,'O','Oxygen',15.9994},{9,'F','Fluorine',18.9984032},{10,'Ne','Neon',20.1797},{11,'Na','Sodium',22.989770},{12,'Mg','Magnesium',24.3050},{13,'Al','Aluminum',26.981538},{14,'Si','Silicon',28.0855},{15,'P','Phosphorus',30.973761},{16,'S','Sulfur',32.066},{17,'Cl','Chlorine',35.4527},{18,'Ar','Argon',39.948},{19,'K','Potassium',39.0983},{20,'Ca','Calcium',40.078},{21,'Sc','Scandium',44.955910},{22,'Ti','Titanium',47.867},{23,'V','Vanadium',50.9415},{24,'Cr','Chromium',51.9961},{25,'Mn','Manganese',54.938049},{26,'Fe','Iron',55.845},{27,'Co','Cobalt',58.933200},{28,'Ni','Nickel',58.6934},{29,'Cu','Copper',63.546},{30,'Zn','Zinc',65.39},{31,'Ga','Gallium',69.723},{32,'Ge','Germanium',72.61},{33,'As','Arsenic',74.92160},{34,'Se','Selenium',78.96},{35,'Br','Bromine',79.904},{36,'Kr','Krypton',83.80},{37,'Rb','Rubidium',85.4678},{38,'Sr','Strontium',87.62},{39,'Y','Yttrium',88.90585},{40,'Zr','Zirconium',91.224},{41,'Nb','Niobium',92.90638},{42,'Mo','Molybdenum',95.94},{43,'Tc','Technetium',98},{44,'Ru','Ruthenium',101.07},{45,'Rh','Rhodium',102.90550},{46,'Pd','Palladium',106.42},{47,'Ag','Silver',107.8682},{48,'Cd','Cadmium',112.411},{49,'In','Indium',114.818},{50,'Sn','Tin',118.710},{51,'Sb','Antimony',121.760},{52,'Te','Tellurium',127.60},{53,'I','Iodine',126.90447},{54,'Xe','Xenon',131.29},{55,'Cs','Cesium',132.90545},{56,'Ba','Barium',137.327},{57,'La','Lanthanum',138.9055},{72,'Hf','Hafnium',178.49},{73,'Ta','Tantalum',180.9479},{74,'W','Tungsten',183.84},{75,'Re','Rhenium',186.207},{76,'Os','Osmium',190.23},{77,'Ir','Iridium',192.217},{78,'Pt','Platinum',195.078},{79,'Au','Gold',196.96655},{80,'Hg','Mercury',200.59},{81,'Tl','Thallium',204.3833},{82,'Pb','Lead',207.2},{83,'Bi','Bismuth',208.98038}}

Have fun I guess

45 Likes

How much time did this take you? All I remember is learning this in school, however it is neat you were able to do this! Nice work!

4 Likes

Oh wow, thanks!

2 Likes

Nice, data!

To give some feedback, I think it’d be more user-friendly to use dictionaries - then you have a better idea of what information you’re actually accessing, by doing something like periodicTable[5].Name instead of periodicTable[5][3] :slightly_smiling_face:

I’ve tried changing your table a bit and adding some missing entries to it - and more than just that, you can also find information about atoms given their symbol or name using a simple metatable :ok_hand:

Structure:

{
	Number = int
	Symbol = string,
	Name = string,
	StdWeight = float,
	Period = int,
	Group = int,
	[IsGas = boolean]
}

Obviously there’s a lot more data that could be supplied here, though.

Module code
return setmetatable({
	{Number = 1, Symbol = 'H', Name = 'Hydrogen', StdWeight = 1.00794, Period = 1, Group = 1, IsGas = true},
	{Number = 2, Symbol = 'He', Name = 'Helium', StdWeight = 4.003, Period = 1, Group = 18, IsGas = true},
	{Number = 3, Symbol = 'Li', Name = 'Lithium', StdWeight = 6.941, Period = 2, Group = 1},
	{Number = 4, Symbol = 'Be', Name = 'Beryllium', StdWeight = 9.012182, Period = 2, Group = 2},
	{Number = 5, Symbol = 'B', Name = 'Boron', StdWeight = 10.811, Period = 2, Group = 13},
	{Number = 6, Symbol = 'C', Name = 'Carbon', StdWeight = 12.0107, Period = 2, Group = 14, IsGas = true},
	{Number = 7, Symbol = 'N', Name = 'Nitrogen', StdWeight = 14.00674, Period = 2, Group = 15, IsGas = true},
	{Number = 8, Symbol = 'O', Name = 'Oxygen', StdWeight = 15.9994, Period = 2, Group = 16, IsGas = true},
	{Number = 9, Symbol = 'F', Name = 'Fluorine', StdWeight = 18.9984032, Period = 2, Group = 17, IsGas = true},
	{Number = 10, Symbol = 'Ne', Name = 'Neon', StdWeight = 20.1797, Period = 3, Group = 18, IsGas = true},
	{Number = 11, Symbol = 'Na', Name = 'Sodium', StdWeight = 22.98977, Period = 3, Group = 1},
	{Number = 12, Symbol = 'Mg', Name = 'Magnesium', StdWeight = 24.305, Period = 3, Group = 2},
	{Number = 13, Symbol = 'Al', Name = 'Aluminum', StdWeight = 26.981538, Period = 3, Group = 13},
	{Number = 14, Symbol = 'Si', Name = 'Silicon', StdWeight = 28.0855, Period = 3, Group = 14},
	{Number = 15, Symbol = 'P', Name = 'Phosphorus', StdWeight = 30.973761, Period = 3, Group = 15, IsGas = true},
	{Number = 16, Symbol = 'S', Name = 'Sulfur', StdWeight = 32.066, Period = 3, Group = 16, IsGas = true},
	{Number = 17, Symbol = 'Cl', Name = 'Chlorine', StdWeight = 35.4527, Period = 3, Group = 17, IsGas = true},
	{Number = 18, Symbol = 'Ar', Name = 'Argon', StdWeight = 39.948, Period = 4, Group = 18, IsGas = true},
	{Number = 19, Symbol = 'K', Name = 'Potassium', StdWeight = 39.0983, Period = 4, Group = 1},
	{Number = 20, Symbol = 'Ca', Name = 'Calcium', StdWeight = 40.078, Period = 4, Group = 2},
	{Number = 21, Symbol = 'Sc', Name = 'Scandium', StdWeight = 44.95591, Period = 4, Group = 3},
	{Number = 22, Symbol = 'Ti', Name = 'Titanium', StdWeight = 47.867, Period = 4, Group = 4},
	{Number = 23, Symbol = 'V', Name = 'Vanadium', StdWeight = 50.9415, Period = 4, Group = 5},
	{Number = 24, Symbol = 'Cr', Name = 'Chromium', StdWeight = 51.9961, Period = 4, Group = 6},
	{Number = 25, Symbol = 'Mn', Name = 'Manganese', StdWeight = 54.938049, Period = 4, Group = 7},
	{Number = 26, Symbol = 'Fe', Name = 'Iron', StdWeight = 55.845, Period = 4, Group = 8},
	{Number = 27, Symbol = 'Co', Name = 'Cobalt', StdWeight = 58.9332, Period = 4, Group = 9},
	{Number = 28, Symbol = 'Ni', Name = 'Nickel', StdWeight = 58.6934, Period = 4, Group = 10},
	{Number = 29, Symbol = 'Cu', Name = 'Copper', StdWeight = 63.546, Period = 4, Group = 11},
	{Number = 30, Symbol = 'Zn', Name = 'Zinc', StdWeight = 65.39, Period = 4, Group = 12},
	{Number = 31, Symbol = 'Ga', Name = 'Gallium', StdWeight = 69.723, Period = 4, Group = 13},
	{Number = 32, Symbol = 'Ge', Name = 'Germanium', StdWeight = 72.61, Period = 4, Group = 14},
	{Number = 33, Symbol = 'As', Name = 'Arsenic', StdWeight = 74.9216, Period = 4, Group = 15},
	{Number = 34, Symbol = 'Se', Name = 'Selenium', StdWeight = 78.96, Period = 4, Group = 16, IsGas = true},
	{Number = 35, Symbol = 'Br', Name = 'Bromine', StdWeight = 79.904, Period = 4, Group = 17, IsGas = true},
	{Number = 36, Symbol = 'Kr', Name = 'Krypton', StdWeight = 83.8, Period = 4, Group = 18, IsGas = true},
	{Number = 37, Symbol = 'Rb', Name = 'Rubidium', StdWeight = 85.4678, Period = 5, Group = 1},
	{Number = 38, Symbol = 'Sr', Name = 'Strontium', StdWeight = 87.62, Period = 5, Group = 2},
	{Number = 39, Symbol = 'Y', Name = 'Yttrium', StdWeight = 88.90585, Period = 5, Group = 3},
	{Number = 40, Symbol = 'Zr', Name = 'Zirconium', StdWeight = 91.224, Period = 5, Group = 4},
	{Number = 41, Symbol = 'Nb', Name = 'Niobium', StdWeight = 92.90638, Period = 5, Group = 5},
	{Number = 42, Symbol = 'Mo', Name = 'Molybdenum', StdWeight = 95.94, Period = 5, Group = 6},
	{Number = 43, Symbol = 'Tc', Name = 'Technetium', StdWeight = 98, Period = 5, Group = 7},
	{Number = 44, Symbol = 'Ru', Name = 'Ruthenium', StdWeight = 101.07, Period = 5, Group = 8},
	{Number = 45, Symbol = 'Rh', Name = 'Rhodium', StdWeight = 102.9055, Period = 5, Group = 9},
	{Number = 46, Symbol = 'Pd', Name = 'Palladium', StdWeight = 106.42, Period = 5, Group = 10},
	{Number = 47, Symbol = 'Ag', Name = 'Silver', StdWeight = 107.8682, Period = 5, Group = 11},
	{Number = 48, Symbol = 'Cd', Name = 'Cadmium', StdWeight = 112.411, Period = 5, Group = 12},
	{Number = 49, Symbol = 'In', Name = 'Indium', StdWeight = 114.818, Period = 5, Group = 13},
	{Number = 50, Symbol = 'Sn', Name = 'Tin', StdWeight = 118.71, Period = 5, Group = 14},
	{Number = 51, Symbol = 'Sb', Name = 'Antimony', StdWeight = 121.76, Period = 5, Group = 15},
	{Number = 52, Symbol = 'Te', Name = 'Tellurium', StdWeight = 127.6, Period = 5, Group = 16},
	{Number = 53, Symbol = 'I', Name = 'Iodine', StdWeight = 126.90447, Period = 5, Group = 17, IsGas = true},
	{Number = 54, Symbol = 'Xe', Name = 'Xenon', StdWeight = 131.29, Period = 5, Group = 18, IsGas = true},
	{Number = 55, Symbol = 'Cs', Name = 'Caesium', StdWeight = 132.90545, Period = 6, Group = 1},
	{Number = 56, Symbol = 'Ba', Name = 'Barium', StdWeight = 137.327, Period = 6, Group = 2},
	{Number = 57, Symbol = 'La', Name = 'Lanthanum', StdWeight = 138.9055, Period = 6, Group = 3},
  {Number = 58, Symbol = 'Ce', Name = 'Cerium', StdWeight = 140.116, Period = 6, Group = 3},
  {Number = 59, Symbol = 'Pr', Name = 'Praseodymium', StdWeight = 140.907, Period = 6, Group = 3},
  {Number = 60, Symbol = 'Nd', Name = 'Neodymium', StdWeight = 144.242, Period = 6, Group = 3},
  {Number = 61, Symbol = 'Pm', Name = 'Promethium', StdWeight = 145, Period = 6, Group = 3},
  {Number = 62, Symbol = 'Sm', Name = 'Samarium', StdWeight = 150.36, Period = 6, Group = 3},
  {Number = 63, Symbol = 'Eu', Name = 'Europium', StdWeight = 151.964, Period = 6, Group = 3},
  {Number = 64, Symbol = 'Gd', Name = 'Gadolinium', StdWeight = 157.25, Period = 6, Group = 3},
  {Number = 65, Symbol = 'Tb', Name = 'Terbium', StdWeight = 158.925, Period = 6, Group = 3},
  {Number = 66, Symbol = 'Dy', Name = 'Dysprosium', StdWeight = 162.5, Period = 6, Group = 3},
  {Number = 67, Symbol = 'Ho', Name = 'Holmium', StdWeight = 164.930, Period = 6, Group = 3},
  {Number = 68, Symbol = 'Er', Name = 'Erbium', StdWeight = 167.259, Period = 6, Group = 3},
  {Number = 69, Symbol = 'Tm', Name = 'Thulium', StdWeight = 168.934, Period = 6, Group = 3},
  {Number = 70, Symbol = 'Yb', Name = 'Ytterbium', StdWeight = 173.045, Period = 6, Group = 3},
  {Number = 71, Symbol = 'Lu', Name = 'Lutetium', StdWeight = 174.9668, Period = 6, Group = 3},
	{Number = 72, Symbol = 'Hf', Name = 'Hafnium', StdWeight = 178.49, Period = 6, Group = 4},
	{Number = 73, Symbol = 'Ta', Name = 'Tantalum', StdWeight = 180.9479, Period = 6, Group = 5},
	{Number = 74, Symbol = 'W', Name = 'Tungsten', StdWeight = 183.84, Period = 6, Group = 6},
	{Number = 75, Symbol = 'Re', Name = 'Rhenium', StdWeight = 186.207, Period = 6, Group = 7},
	{Number = 76, Symbol = 'Os', Name = 'Osmium', StdWeight = 190.23, Period = 6, Group = 8},
	{Number = 77, Symbol = 'Ir', Name = 'Iridium', StdWeight = 192.217, Period = 6, Group = 9},
	{Number = 78, Symbol = 'Pt', Name = 'Platinum', StdWeight = 195.078, Period = 6, Group = 10},
	{Number = 79, Symbol = 'Au', Name = 'Gold', StdWeight = 196.96655, Period = 6, Group = 11},
	{Number = 80, Symbol = 'Hg', Name = 'Mercury', StdWeight = 200.59, Period = 6, Group = 12},
	{Number = 81, Symbol = 'Tl', Name = 'Thallium', StdWeight = 204.3833, Period = 6, Group = 13},
	{Number = 82, Symbol = 'Pb', Name = 'Lead', StdWeight = 207.2, Period = 6, Group = 14},
	{Number = 83, Symbol = 'Bi', Name = 'Bismuth', StdWeight = 208.98038, Period = 6, Group = 15},
  {Number = 84, Symbol = 'Po', Name = 'Polonium', StdWeight = 209, Period = 6, Group = 16},
  {Number = 85, Symbol = 'At', Name = 'Astatine', StdWeight = 210, Period = 6, Group = 17},
  {Number = 86, Symbol = 'Rn', Name = 'Radon', StdWeight = 222, Period = 6, Group = 18, IsGas = true},
  {Number = 87, Symbol = 'Fr', Name = 'Francium', StdWeight = 223, Period = 7, Group = 1},
  {Number = 88, Symbol = 'Ra', Name = 'Radium', StdWeight = 226, Period = 7, Group = 2},
  {Number = 89, Symbol = 'Ac', Name = 'Actinium', StdWeight = 227, Period = 7, Group = 3},
  {Number = 90, Symbol = 'Th', Name = 'Thorium', StdWeight = 232.0377, Period = 7, Group = 3},
  {Number = 91, Symbol = 'Pa', Name = 'Protactinium', StdWeight = 231.035, Period = 7, Group = 3},
  {Number = 92, Symbol = 'U', Name = 'Uranium', StdWeight = 238.028, Period = 7, Group = 3},
  {Number = 93, Symbol = 'Np', Name = 'Neptunium', StdWeight = 237, Period = 7, Group = 3},
  {Number = 94, Symbol = 'Pu', Name = 'Plutonium', StdWeight = 244, Period = 7, Group = 3},
  {Number = 95, Symbol = 'Am', Name = 'Americium', StdWeight = 243, Period = 7, Group = 3},
  {Number = 96, Symbol = 'Cm', Name = 'Curium', StdWeight = 247, Period = 7, Group = 3},
  {Number = 97, Symbol = 'Bk', Name = 'Berkelium', StdWeight = 247, Period = 7, Group = 3},
  {Number = 98, Symbol = 'Cf', Name = 'Californium', StdWeight = 251, Period = 7, Group = 3},
  {Number = 99, Symbol = 'Es', Name = 'Einsteinium', StdWeight = 252, Period = 7, Group = 3},
  {Number = 100, Symbol = 'Fm', Name = 'Fermium', StdWeight = 257, Period = 7, Group = 3},
  {Number = 101, Symbol = 'Md', Name = 'Mendelevium', StdWeight = 258, Period = 7, Group = 3},
  {Number = 102, Symbol = 'No', Name = 'Nobelium', StdWeight = 259, Period = 7, Group = 3},
  {Number = 103, Symbol = 'Lr', Name = 'Lawrencium', StdWeight = 266, Period = 7, Group = 3},
  {Number = 104, Symbol = 'Rf', Name = 'Rutherfordium', StdWeight = 267, Period = 7, Group = 4},
  {Number = 105, Symbol = 'Db', Name = 'Dubnium', StdWeight = 268, Period = 7, Group = 5},
  {Number = 106, Symbol = 'Sg', Name = 'Seaborgium', StdWeight = 269, Period = 7, Group = 6},
  {Number = 107, Symbol = 'Bh', Name = 'Bohrium', StdWeight = 270, Period = 7, Group = 7},
  {Number = 108, Symbol = 'Hs', Name = 'Hassium', StdWeight = 270, Period = 7, Group = 8},
  {Number = 109, Symbol = 'Mt', Name = 'Meitnerium', StdWeight = 278, Period = 7, Group = 9},
  {Number = 110, Symbol = 'Ds', Name = 'Darmstadtium', StdWeight = 281, Period = 7, Group = 10},
  {Number = 111, Symbol = 'Rg', Name = 'Roentgenium', StdWeight = 282, Period = 7, Group = 11},
  {Number = 112, Symbol = 'Cn', Name = 'Copernicium', StdWeight = 285, Period = 7, Group = 12},
  {Number = 113, Symbol = 'Nh', Name = 'Nihonium', StdWeight = 286, Period = 7, Group = 13},
  {Number = 114, Symbol = 'Fl', Name = 'Flevorium', StdWeight = 289, Period = 7, Group = 14},
  {Number = 115, Symbol = 'Mc', Name = 'Moscovium', StdWeight = 290, Period = 7, Group = 15},
  {Number = 116, Symbol = 'Lv', Name = 'Livermorium', StdWeight = 293, Period = 7, Group = 16},
  {Number = 117, Symbol = 'Ts', Name = 'Tennessine', StdWeight = 294, Period = 7, Group = 17},
  {Number = 118, Symbol = 'Og', Name = 'Oganesson', StdWeight = 294, Period = 7, Group = 18}
}, {
  __index = function(tabl, key)
    if type(key) == "string" then
      for i = 1, #tabl do
        if (tabl[i].Symbol == key or tabl[i].Name == key) then
          return tabl[i]
        end
      end
    end
  end
})

Example of usage:

local PeriodicTable = require(modulescript)

print(PeriodicTable["Au"].Name) -- Gold
print(PeriodicTable["Plutonium"].Period) -- 7
print(PeriodicTable[28].StdWeight) -- 58.6934, check Nickel
26 Likes

LOL well for my usage I didn’t care enough to actually go that far in depth with it, but nice.

6 Likes

What did you use the one you made for?

1 Like

I made a small little game called atom simulator and as you gained electrons your atom type changed.

3 Likes

Where’s all the Radioactive ones? Such as Thorium :cool:

Sounds like fun!

I think this table is a little outdated, I got the info from a pretty old looking website.

1 Like

Oh well, but your list is like this 56 > 57 > 72 > 73 etc which clearly shows some of the radioactive ones are skipped.

1 Like

This is gonna be useful to me someday. I don’t know when, but I will eventually return to this thread and bless your soul.

4 Likes

Write it into a program for a calculator, next chemistry class will be a breeze!

4 Likes

Seems like a cool and useful table for periodic table in Roblox :smiley: , but I prefer to forget about this table from school xD

2 Likes

Ive done this before except it used http service on some up-to-date website and parsed the html table so it always had the newer elements name definitions. Also, the atomic number should not be necessary considering it is ordered by their atomic number so it can just be an array.

Edit: I found the code so

local http = game:GetService('HttpService')
local tbl = http:GetAsync('https://ptable.com/')
local elements = {}

for element in tbl:gmatch('<td class="Element.-</a></td>') do
	local an = element:match('<strong.->(.-)<')*1
	local short = element:match('<acronym>(.-)<')
	local long = element:match('<em.->(.-)<')
	local mass = element:match('<i>%(?(.-)%)?<')*1
	elements[an] = {
		Number = an,
		Name = long,
		Nickname = short,
		Mass = mass
	}
end

I think the newer one supported groups and periods but cant find it

6 Likes

when you have too much free time

good job though i like it

1 Like

I actually wrote a script to parse the copied text from the website and format it as a table.

Id send the code but I have no clue where it is.

check out the periodic table i created based on your work
Desktop 2024.07.19 - 21.04.30.20
Desktop 2024.07.19 - 21.04.58.21

2 Likes