Advertisement
KnightZoro

Jungle Generator

Aug 15th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. size = 240
  2.  
  3. CA = CFrame.Angles
  4. CN = CFrame.new
  5. V3 = Vector3.new
  6. MR = math.rad
  7. MP = math.pi
  8. MRA = math.random
  9. MH = math.huge
  10.  
  11. Wood = {"Brown", "Reddish brown"}
  12. Leaves = {"Earth green", "Bright green", "Dark green", "Camo"}
  13. LeafMeshes = {{"http://www.roblox.com/asset/?id=16659363", V3(2.05,-1.6,2.05)},
  14. {"http://www.roblox.com/asset/?id=1091940", V3(1.2,0.6,1.2)}}
  15.  
  16. Rock = {"Medium grey", "Dark grey"}
  17.  
  18. Add = {
  19. Mesh = function(P, Id, Id2, scale)
  20. local m = Instance.new("SpecialMesh", P)
  21. m.Scale = scale
  22. m.MeshId = Id
  23. m.TextureId = Id2
  24. end
  25. }
  26.  
  27. function Part(P, Anch, Coll, Tran, Ref, Col, X, Y, Z)
  28. local p = Instance.new("Part")
  29. p.TopSurface = 0
  30. p.BottomSurface = 0
  31. p.Transparency = Tran
  32. p.Reflectance = Ref
  33. p.CanCollide = Coll
  34. p.Anchored = Anch
  35. p.BrickColor = BrickColor.new(Col)
  36. p.formFactor = "Custom"
  37. p.Size = V3(X,Y,Z)
  38. p.Parent = P
  39. p.Locked = true
  40. p:BreakJoints()
  41. return p
  42. end
  43.  
  44. Mod = Instance.new("Model",workspace)
  45. Mod.Name = "Jungle"
  46.  
  47. Models = {
  48. function(cf, siz)
  49. local m = Instance.new("Model",Mod)
  50. local cen = cf * CN(0, 0, -38*siz)
  51. local wo = Wood[MRA(1,#Wood)]
  52. local le = Leaves[MRA(1,#Leaves)]
  53. local last = nil
  54. for i = 0, 1, 0.2 do
  55. local p = Part(m, true, true, 0, 0, wo, 3*siz, 5.7*siz, 3*siz)
  56. Instance.new("SpecialMesh",p)
  57. p.CFrame = cen * CA(MR(-40*i), 0, 0) * CN(0, 0, 38*siz)
  58. if wo == Wood[1] then wo = Wood[2] else wo = Wood[1] end
  59. last = p
  60. end
  61. local messa = LeafMeshes[MRA(1,#LeafMeshes)]
  62. local a = -3
  63. if messa == LeafMeshes[1] then
  64. a = 0.4
  65. end
  66. last.BrickColor = BrickColor.new(le)
  67. local p = Part(m, true, false, 0, 0, le, 0.2, 0.2, 0.2)
  68. local m = Add.Mesh(p, messa[1], "", V3((messa[2].X*10)*siz,(messa[2].Y*10)*siz,(messa[2].Z*10)*siz))
  69. p.CFrame = last.CFrame * CN(0, a*siz, 0) * CA(MP+MR(20), 0, 0)
  70. end,
  71. function(cf, siz)
  72. local m = Instance.new("Model",Mod)
  73. local ro1, ro2 = Rock[MRA(1,#Rock)], Rock[MRA(1,#Rock)]
  74. local p = Part(m, true, true, 0, 0, ro1, 7.5*siz, 7.5*siz, 7.5*siz)
  75. p.CFrame = cf * CN(0, 1.8*siz, 4*siz) * CA(MR(MRA(-180,180)), MR(MRA(-180,180)), MR(MRA(-180,180)))
  76. local ms = Add.Mesh(p, "http://www.roblox.com/asset/?id=1290033", "", V3(5*siz, 5*siz, 5*siz))
  77.  
  78. local p2 = Part(m, true, true, 0, 0, ro2, 5.5*siz, 5.5*siz, 5.5*siz)
  79. p2.CFrame = cf * CN(7*siz, 1.5*siz, -6*siz) * CA(MR(MRA(-180,180)), MR(MRA(-180,180)), MR(MRA(-180,180)))
  80. local ms2 = Add.Mesh(p2, "http://www.roblox.com/asset/?id=1290033", "", V3(3.8*siz, 3.8*siz, 3.8*siz))
  81. end,
  82. function(cf, siz)
  83. local m = Instance.new("Model",Mod)
  84. local le = Leaves[MRA(1,#Leaves)]
  85.  
  86. local p = Part(m, true, false, 0, 0, le, 0.2, 0.2, 0.2)
  87. p.CFrame = cf * CN(2*siz, 1.6*siz, -4*siz) * CA(0, 0, 0)
  88. local ms = Add.Mesh(p, "http://www.roblox.com/asset/?id=1095708", "", V3(12*siz, 11*siz, 10*siz))
  89.  
  90. local p2 = Part(m, true, false, 0, 0, le, 0.2, 0.2, 0.2)
  91. p2.CFrame = cf * CN(-4*siz, 1.1*siz, -1*siz) * CA(0, MR(-34), 0)
  92. local ms2 = Add.Mesh(p2, "http://www.roblox.com/asset/?id=1095708", "", V3(10*siz, 7.5*siz, 8*siz))
  93. end,
  94. function(cf, siz)
  95. local m = Instance.new("Model",Mod)
  96.  
  97. local p = Part(m, true, false, 0, 0, "Bright green", 0.2, 0.2, 0.2)
  98. p.CFrame = cf * CN(2*siz, 1.1*siz, -4*siz) * CA(0, 0, 0)
  99. local ms = Add.Mesh(p, "http://www.roblox.com/asset/?id=16659363", "http://www.roblox.com/asset/?id=16659355", V3(10*siz, 14*siz, 10*siz))
  100.  
  101. local p2 = Part(m, true, false, 0, 0, "Bright green", 0.2, 0.2, 0.2)
  102. p2.CFrame = cf * CN(-4*siz, 0.7*siz, 1*siz) * CA(MR(MRA(-15,15)), MR(MRA(-180,180)), MR(MRA(-15,15)))
  103. local ms2 = Add.Mesh(p2, "http://www.roblox.com/asset/?id=16659363", "http://www.roblox.com/asset/?id=16659355", V3(7*siz, 11*siz, 6*siz))
  104. end,
  105. function(cf, siz)
  106. local m = Instance.new("Model",Mod)
  107.  
  108. local p = Part(m, true, true, 0, 0, "White", 1.2*siz, 6*siz, 1.2*siz)
  109. p.CFrame = cf * CN((MRA(-4*100,4*100)/100)*siz, 3.2*siz, (MRA(-4*100,4*100)/100)*siz) * CA(0, MR(MRA(-180,180)), 0)
  110. local ms = Add.Mesh(p, "http://www.roblox.com/asset/?id=1090398", "http://www.roblox.com/asset/?id=1090399", V3(3.5*siz, 5*siz, 3.5*siz))
  111. end,
  112. function(cf, siz)
  113. local m = Instance.new("Model",Mod)
  114. local col = Wood[MRA(1,#Wood)]
  115. local p = Part(m, true, true, 0, 0, col, 2.8*siz, 22*siz, 2.8*siz)
  116. Instance.new("SpecialMesh",p)
  117. p.CFrame = cf * CN((MRA(-4*100,4*100)/100)*siz, 11*siz, (MRA(-4*100,4*100)/100)*siz) * CA(0, MR(MRA(-180,180)), 0)
  118. local leave = Leaves[MRA(1, #Leaves)]
  119. local mes = LeafMeshes[MRA(1, #LeafMeshes)]
  120. local a = 3
  121. local ca = CA(MR(MRA(-30, 30)), MR(MRA(-180, 180)), MR(MRA(-30, 30)))
  122. if mes == LeafMeshes[1] then
  123. a = -0.5
  124. ca = ca * CA(MP, 0, 0)
  125. end
  126. for i = 1, MRA(1,5) do
  127. local cf2 = p.CFrame * CA(0, MR(MRA(-180,180)), 0) * CN(0, (MRA(2*100, 14*100)/100)*siz, -1.4*siz)
  128. local center = cf2 * CN(0, 0, -8*siz) * CA(0, 0, 0)
  129. local first = nil
  130. for x = 0, 45, 15 do
  131. local p2 = Part(m, true, true, 0, 0, col, 2.5*siz, 4*siz, 2.5*siz)
  132. Instance.new("SpecialMesh", p2)
  133. p2.CFrame = center * CN(0, 0, 4*siz) * CA(MR(x), 0, 0) * CN(0, 0, 10*siz) * CA(0, 0, 0)
  134. if first == nil then first = p2 end
  135. end
  136. local p3 = Part(m, true, false, 0, 0, leave, 0.2, 0.2, 0.2)
  137. Add.Mesh(p3, mes[1], "", (mes[2]*7)*siz)
  138. local ca2 = CA(MR(MRA(-30, 30)), MR(MRA(-180, 180)), MR(MRA(-30, 30)))
  139. if mes == LeafMeshes[1] then
  140. ca2 = ca2 * CA(MP, 0, 0)
  141. end
  142. p3.CFrame = first.CFrame * CN(0, a*siz, 0) * ca2
  143. end
  144. local p3 = Part(m, true, false, 0, 0, leave, 0.2, 0.2, 0.2)
  145. Add.Mesh(p3, mes[1], "", (mes[2]*9)*siz)
  146. local cn = p.CFrame * CN(0, 11*siz, 0)
  147. p3.CFrame = cn * CN(0, a*siz, 0) * ca
  148. end,
  149. }
  150.  
  151. pos = CN(0, 0, 0)
  152.  
  153.  
  154. local base = Part(Mod, true, true, 0, 0, Leaves[MRA(1,#Leaves)], size, 1, size)
  155. base.CFrame = pos * CN(0, 1, 0)
  156. base.Material = "Grass"
  157.  
  158. for x = -size/2, size/2, 20 do
  159. for z = -size/2, size/2, 20 do
  160. Models[MRA(1, #Models)](pos * CN(x+(MRA(-4*1000, 4*1000)/1000), 1.2, z+(MRA(-4*1000, 4*1000)/1000)) * CA(0, MR(MRA(-180,180)), 0), MRA(1.1*100, 2.4*100)/100)
  161. end
  162. wait(0.2)
  163. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement