Advertisement
memesbruh03

terrain gen

Aug 31st, 2016
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.23 KB | None | 0 0
  1. local size = 40--Size of Terrain Bricks(Smallest Size)
  2. local maxsize = 70--Size of Terrain Bricks(Largest Size)
  3. local tilt = math.random(-12,12) --Tilt of terrain(0 for no tilt) Best to be between 0 to 12
  4.  
  5. local amount = 300 --Amount of Bricks
  6.  
  7. width = 200 -- Max Width of Terrain
  8. height = 30 --Max Height of Terrain(HAS TO BE EVEN NUMBER!!)
  9.  
  10. terrain = 1 --Type Of Terrain (0=Sphere,1=Brick,2=Cylinder)
  11.  
  12. water = true --Put false for no Water
  13. watersize = 20 --Size(If water is true) Best to be inBetween 2 to 12
  14. waterlevel = 2 --height of water(If water is true) Should be between 1 to 2 (Lower Number creates less land Above water)
  15.  
  16. customcolor = "Olivine" --Terrain BrickColor(If autocolor is false)
  17. material = "Grass" --Terrain Material                                                                                                                                          
  18.                                                                                                                                                                                                
  19. autocolor = true --Automatic Terrain Coloring(set false for no autocolor)      
  20.  
  21. trees = true --Set to false if You want No trees     --->(A Bit Glitchy) :/
  22. treeamount = 200  --Number of Trees
  23. leavetrim = 1 --Shape Of Leaves(0=Sphere,1=Brick,2=Cylinder)    
  24. leavesize = 20 --Size of leaves                                                                                                                                                                                                                                              
  25. --                                                                                                                                                                                                    
  26. --                                                                                                                                                                                                  
  27. --------------------------------------                                                                               
  28. --Don't Mess with the Below--|                                                                             
  29. -------------------------------------------------------------------------------------------------------------------------------------------------------------
  30. local m = Instance.new("Message",workspace)
  31. m.Text = "Prepare yourself for terrain generation in 5..."
  32. local s = Instance.new("Sound",workspace)
  33. s.SoundId = "rbxasset://sounds/electronicpingshort.wav"
  34. s.Volume = 1
  35. s.Pitch = 2.7
  36. s.PlayOnRemove = true
  37. s:Remove()
  38. wait(1)
  39. m.Text = "Prepare yourself for terrain generation in 4..."
  40. local s = Instance.new("Sound",workspace)
  41. s.SoundId = "rbxasset://sounds/electronicpingshort.wav"
  42. s.Volume = 1
  43. s.Pitch = 2.7
  44. s.PlayOnRemove = true
  45. s:Remove()
  46. wait(1)
  47. m.Text = "Prepare yourself for terrain generation in 3..."
  48. local s = Instance.new("Sound",workspace)
  49. s.SoundId = "rbxasset://sounds/electronicpingshort.wav"
  50. s.Volume = 1
  51. s.Pitch = 2.7
  52. s.PlayOnRemove = true
  53. s:Remove()
  54. wait(1)
  55. m.Text = "Prepare yourself for terrain generation in 2..."
  56. local s = Instance.new("Sound",workspace)
  57. s.SoundId = "rbxasset://sounds/electronicpingshort.wav"
  58. s.Volume = 1
  59. s.Pitch = 2.7
  60. s.PlayOnRemove = true
  61. s:Remove()
  62. wait(1)
  63. m.Text = "Prepare yourself for terrain generation in 1..."
  64. local s = Instance.new("Sound",workspace)
  65. s.SoundId = "rbxasset://sounds/electronicpingshort.wav"
  66. s.Volume = 1
  67. s.Pitch = 2.7
  68. s.PlayOnRemove = true
  69. s:Remove()
  70. wait(1)
  71. local h = Instance.new("Hint",workspace)
  72. h.Text = "Please wait for the generation to complete."
  73.  
  74. local collect = Instance.new("Model")
  75. collect.Parent = game.Workspace
  76. collect.Name = "Terrain"
  77.  
  78. rock = "Dark stone grey"
  79. grass = {"Bright green","Dark green","Olive","Olivine","Moss","Forest green","Sea green","Medium green","Mint","Pastel green","Sand green","Br. yellowish green","Artichoke","Sage green","Grime","Camo","Shamrock","Parsley green","Earth green","Slime green"}
  80. sand = "Brick yellow"
  81.  
  82. local value = 0
  83. for i = 1,amount do -->Main function
  84. value = value +1
  85. m.Text = "Adding Terrain #"..value
  86. local land = Instance.new("Part")
  87. land.Name = "Land "..value
  88. land.Parent = collect
  89. land.Anchored = true
  90. land.Shape = terrain
  91. land.Material = material
  92. e = math.random(size,maxsize)
  93. land.Size = Vector3.new(e,e,e)
  94. if autocolor == false then land.BrickColor = BrickColor.new(customcolor) end
  95. land.CFrame = CFrame.new(math.random(-width,width),math.random(0,height),math.random(-width,width))
  96. --land.CFrame = CFrame.new(math.random(-posX,posZ),math.random(-depth,height),math.random(-posX,posZ))
  97. land.CFrame = land.CFrame * CFrame.fromEulerAnglesXYZ(0,tilt,0)
  98. grasses = grass[math.random(1, #grass)]
  99. local k = Instance.new("Hint",workspace)
  100. k.Text = "autocolor was set true! autocoloring..." --autocolor Responses below
  101. k:Remove()
  102. if autocolor == true and land.Position.y >= height/1.125 then
  103. land.BrickColor = BrickColor.new(rock)
  104. land.Material = "Slate"
  105. end
  106. if autocolor == true and land.Position.y >= height/4 and land.Position.y <= height/1.125 then
  107. land.BrickColor = BrickColor.new(grasses)
  108. end
  109. if autocolor == true and land.Position.y <= height/4 then
  110. land.BrickColor = BrickColor.new(sand)
  111. land.Material = "Sand"
  112. end
  113. wait()
  114. local s = Instance.new("Sound",workspace)
  115. s.SoundId = "rbxassetid://15666462"
  116. s.Volume = 1
  117. s.Pitch = 3.6
  118. s.PlayOnRemove = true
  119. s:Remove()
  120. end
  121.            
  122. --extras v
  123.  
  124. local value2 = 0
  125. m.Text = "Creating trees..."
  126. if trees == true then
  127. for t = 1,treeamount do --Who would of known the complications...of growing a Tree...
  128. value2 = value2 +1
  129. local tree = Instance.new("Model")
  130. tree.Parent = collect
  131. tree.Name = "Tree " ..value2
  132. local trunk = Instance.new("Part")
  133. trunk.Parent = tree
  134. trunk.Name = "Trunk"
  135. trunk.Material = "Wood"
  136. trunk.Anchored = true
  137. trunk.Size = Vector3.new(2,height +height*0.7,2)
  138. trunk.BrickColor = BrickColor.new("Brown") --Hard To set CFrames for these
  139. trunk.CFrame = CFrame.new(math.random(-width,width),math.random(height/1.1,height +height*0.7),math.random(-width,width))
  140. local leaves = Instance.new("Part")
  141. leaves.Parent = tree
  142. leaves.Name = "Leaves"
  143. leaves.Material = "Grass"
  144. leaves.Anchored = true
  145. leaves.Shape = leavetrim
  146. leaves.Size = Vector3.new(leavesize,leavesize,leavesize)
  147. leaves.BrickColor = BrickColor.new(grasses)
  148. leaves.CFrame = trunk.CFrame + Vector3.new(0,trunk.Size.y*0.5,0)
  149. leaves.CanCollide = false
  150. wait()
  151. local s = Instance.new("Sound",workspace)
  152. s.SoundId = "rbxassetid://15666462"
  153. s.Volume = 1
  154. s.Pitch = 1.4
  155. s.PlayOnRemove = true
  156. s:Remove()
  157. end
  158. end
  159.  
  160. if water == true then
  161. m.Text = "Ok to make Water"
  162. local water = Instance.new("Part")
  163. water.Name = "Water"
  164. water.Parent = collect
  165. water.Transparency = 0.5
  166. water.CanCollide = false
  167. water.Anchored = true
  168. water.TopSurface = "Smooth"
  169. water.BottomSurface = "Smooth"
  170. water.BrickColor = BrickColor.new("Bright bluish green")
  171. water.Size = Vector3.new(width*watersize,1,width*watersize)
  172. water.CFrame = CFrame.new(0,height/waterlevel,0) --Possible Glitches?
  173. workspace.Base:Remove()
  174. end
  175. m.Text = "Completed Terrain Generation"
  176. h.Text = "Completed Terrain Generation"
  177. local s = Instance.new("Sound",workspace)
  178. s.SoundId = "rbxasset://sounds/electronicpingshort.wav"
  179. s.Volume = 1
  180. s.Pitch = 2.7
  181. s.PlayOnRemove = true
  182. s:Remove()
  183. wait(2)
  184. m:Remove()
  185. h:Remove()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement