Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Loop=3
- local DefPosition=Vector3.new(100,30,0)
- if owner then DefPosition=owner.Character.HumanoidRootPart.CFrame.p+Vector3.new(0,20,0) end
- local Collide=false
- local Color=Color3.new(1,1,1)
- local BlockCount=0
- local Removed=0 local Transparent=0
- l00p=4
- local limit=24 local lcount=0
- local File=Instance.new("Folder",workspace)File.Name="Fractal"
- if owner then File.Parent=owner.Character end
- local function Erase()
- File:Destroy()
- File=Instance.new("Folder",workspace)File.Name="Fractal"
- end
- local function sw(num)
- if num~=nil then
- for i=1,num do
- game:service("RunService").Heartbeat:wait()end
- else game:service("RunService").Heartbeat:wait()
- end
- end
- function ToMesh(Part)
- local Mesh=Instance.new("SpecialMesh",Part)
- if Part.Shape==Enum.PartType.Block then Mesh.MeshType="Brick"elseif Part.Shape==Enum.PartType.Ball then Mesh.MeshType="Sphere"elseif Part.Shape==Enum.PartType.Cylinder then Mesh.MeshType="Cylinder"end
- Mesh.Scale=Part.Size*20 Part.Size=Vector3.new()
- return Mesh
- end
- function SetPart2D(Siz,Pos,Parent)--wait()
- lcount=lcount+1
- if lcount>limit then sw(4)lcount=0 end
- local pt=Instance.new("Part",Parent)
- pt.Size=Vector3.new(Siz,.5,Siz)
- pt.Color=Color
- pt.CanCollide=Collide
- pt.Material="SmoothPlastic"pt.Transparency=Transparent
- pt.Anchored=true
- pt.CFrame=CFrame.new(Pos)
- Instance.new("BlockMesh",pt).Scale=Vector3.new(1,1,1)
- BlockCount=BlockCount+1
- return pt
- end
- function Sierpinski_carpet(Part,Loop,RemovePart)
- if Loop>0 then
- local OutputTo=Part
- if RemovePart then
- Part:Destroy()Removed=Removed+1
- OutputTo=File
- end
- local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(Part.Size.X,0,0),OutputTo)
- Sierpinski_carpet(pt,Loop-1,RemovePart)
- local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(Part.Size.X,0,Part.Size.Z),OutputTo)
- Sierpinski_carpet(pt,Loop-1,RemovePart)
- local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(0,0,Part.Size.Z),OutputTo)
- Sierpinski_carpet(pt,Loop-1,RemovePart)
- local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(-Part.Size.X,0,Part.Size.Z),OutputTo)
- Sierpinski_carpet(pt,Loop-1,RemovePart)
- local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(-Part.Size.X,0,0),OutputTo)
- Sierpinski_carpet(pt,Loop-1,RemovePart)
- local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(-Part.Size.X,0,-Part.Size.Z),OutputTo)
- Sierpinski_carpet(pt,Loop-1,RemovePart)
- local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(0,0,-Part.Size.Z),OutputTo)
- Sierpinski_carpet(pt,Loop-1,RemovePart)
- local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(Part.Size.X,0,-Part.Size.Z),OutputTo)
- Sierpinski_carpet(pt,Loop-1,RemovePart)
- end
- end
- local part=SetPart2D(30,DefPosition,File)
- Sierpinski_carpet(part,l00p,true)
- print("Fractal "..tostring(l00p))
- print"Result .."
- print("Parts : "..tostring(BlockCount))
- print("Removed Parts : "..tostring(Removed))
- print(""..tostring(BlockCount-Removed).." blocks are alive.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement