Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --just an amateur trying to figure out how to do this lol
- local parts = Instance.new("Folder",script)
- local subatomic_particles = {
- neutron = {
- mass = 1,
- charge = 0,
- color = Color3.new(0,1,1),
- size = 1,
- },
- proton = {
- mass = 1,
- charge = 1,
- color = Color3.new(1,0,0),
- size = 1,
- },
- electron = {
- mass = 1/1840, -- 0 or 1/1840
- charge = -1,
- color = Color3.new(0.3,0.3,0.3),
- size = 0.1,
- },
- }
- local atoms = {
- hydrogen = {
- n = 1,
- p = 1,
- e = 1,
- }
- }
- function get_subatom(n)
- return subatomic_particles[n]
- end
- function get_atom(n)
- return atoms[n]
- end
- function create_subatomic_particle(t,pos)
- local pdata = get_subatom(t)
- if pdata then
- local size = pdata.size
- local p = Instance.new("Part")
- p.Massless = true
- --p.Mass = pdata.mass/1000
- p.CanCollide = false
- p.CastShadow = false
- p.Anchored = true
- p.Size = Vector3.new(size,size,size)
- p.Shape = Enum.PartType.Ball
- p.Color = pdata.color
- p.Name = t
- p.Position = pos+Vector3.new(math.random()*5,math.random()*5,math.random()*5)
- p.Parent = parts
- end
- end
- function create_atom(t,pos)
- local atom = get_atom(t)
- local n,p,e = atom.n,atom.p,atom.e
- for i = 1,n do
- create_subatomic_particle('neutron',pos)
- end
- for i = 1,p do
- create_subatomic_particle('proton',pos)
- end
- for i = 1,e do
- create_subatomic_particle('electron',pos)
- end
- end
- function create_covalent_bond(a1,a2)
- end
- function create_ionic_bond(a1,a2)
- end
- create_atom('hydrogen',Vector3.new(50,10,-50))
- function nearest_part(t,pos)
- local dist = math.huge
- local closest = nil
- for _,p in pairs(parts:GetChildren()) do
- local cdist = (pos-p.Position).Magnitude
- if p.Name == t and dist > cdist then
- dist = cdist
- closest = p
- end
- end
- return closest,dist
- end
- function goto(a1,a2,dist)
- local diff = a2.Position-a1.Position
- game:GetService("TweenService"):Create(a1,TweenInfo.new(dist/10,Enum.EasingStyle.Bounce,Enum.EasingDirection.In),{
- Position = a1.Position+(diff*math.random()*1.5)
- }):Play()
- end
- function update() -- move the things or something lol
- for _,p in pairs(parts:GetChildren()) do
- local pos = p.Position
- if p.Name == 'proton' then
- local closest,dist = nearest_part('neutron',pos)
- if closest then
- goto(p,closest,dist)
- end
- elseif p.Name == 'neutron' then
- local closest,dist = nearest_part('proton',pos)
- if closest then
- goto(p,closest,dist)
- end
- elseif p.Name == 'electron' then
- local closest,dist = nearest_part('proton',pos)
- if closest then
- goto(p,closest,dist)
- end
- end
- end
- end
- while true do
- update()
- wait(0)
- end
Add Comment
Please, Sign In to add comment