Advertisement
tomonaoboys

near to fractal

Feb 5th, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.93 KB | None | 0 0
  1. local Loop=3
  2. local DefPosition=Vector3.new(100,30,0)
  3. if owner then DefPosition=owner.Character.HumanoidRootPart.CFrame.p+Vector3.new(0,20,0) end
  4. local Collide=false
  5. local Color=Color3.new(1,1,1)
  6. local BlockCount=0
  7. local Removed=0 local Transparent=0
  8. l00p=4
  9. local limit=24 local lcount=0
  10. local File=Instance.new("Folder",workspace)File.Name="Fractal"
  11. if owner then File.Parent=owner.Character end
  12. local function Erase()
  13.     File:Destroy()
  14.     File=Instance.new("Folder",workspace)File.Name="Fractal"
  15. end
  16. local function sw(num)
  17.     if num~=nil then
  18.     for i=1,num do
  19.     game:service("RunService").Heartbeat:wait()end
  20.     else game:service("RunService").Heartbeat:wait()
  21.     end
  22. end
  23. function ToMesh(Part)
  24.     local Mesh=Instance.new("SpecialMesh",Part)
  25.     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
  26.     Mesh.Scale=Part.Size*20 Part.Size=Vector3.new()
  27.     return Mesh
  28. end
  29. function SetPart2D(Siz,Pos,Parent)--wait()
  30.     lcount=lcount+1
  31.     if lcount>limit then sw(4)lcount=0 end
  32.     local pt=Instance.new("Part",Parent)
  33.     pt.Size=Vector3.new(Siz,.5,Siz)
  34.     pt.Color=Color
  35.     pt.CanCollide=Collide
  36.     pt.Material="SmoothPlastic"pt.Transparency=Transparent
  37.     pt.Anchored=true
  38.     pt.CFrame=CFrame.new(Pos)
  39.     Instance.new("BlockMesh",pt).Scale=Vector3.new(1,1,1)
  40.     BlockCount=BlockCount+1
  41.     return pt
  42. end
  43. function Sierpinski_carpet(Part,Loop,RemovePart)
  44.     if Loop>0 then
  45.     local OutputTo=Part
  46.     if RemovePart then
  47.     Part:Destroy()Removed=Removed+1
  48.     OutputTo=File
  49.     end
  50.     local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(Part.Size.X,0,0),OutputTo)
  51.     Sierpinski_carpet(pt,Loop-1,RemovePart)
  52.     local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(Part.Size.X,0,Part.Size.Z),OutputTo)
  53.     Sierpinski_carpet(pt,Loop-1,RemovePart)
  54.     local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(0,0,Part.Size.Z),OutputTo)
  55.     Sierpinski_carpet(pt,Loop-1,RemovePart)
  56.     local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(-Part.Size.X,0,Part.Size.Z),OutputTo)
  57.     Sierpinski_carpet(pt,Loop-1,RemovePart)
  58.     local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(-Part.Size.X,0,0),OutputTo)
  59.     Sierpinski_carpet(pt,Loop-1,RemovePart)
  60.     local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(-Part.Size.X,0,-Part.Size.Z),OutputTo)
  61.     Sierpinski_carpet(pt,Loop-1,RemovePart)
  62.     local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(0,0,-Part.Size.Z),OutputTo)
  63.     Sierpinski_carpet(pt,Loop-1,RemovePart)
  64.     local pt=SetPart2D(Part.Size.X/3,Part.Position+Vector3.new(Part.Size.X,0,-Part.Size.Z),OutputTo)
  65.     Sierpinski_carpet(pt,Loop-1,RemovePart)
  66.     end
  67. end
  68. local part=SetPart2D(30,DefPosition,File)
  69. Sierpinski_carpet(part,l00p,true)
  70. print("Fractal "..tostring(l00p))
  71. print"Result .."
  72. print("Parts : "..tostring(BlockCount))
  73. print("Removed Parts : "..tostring(Removed))
  74. print(""..tostring(BlockCount-Removed).." blocks are alive.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement