Advertisement
Shyvha

Desert plains V1.1.3 (CACTIS ZOMG shrieks)

Jul 28th, 2017
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.69 KB | None | 0 0
  1. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2. -- Shyvha, 2017. Partially based off @CloneTrooper1019, 2015
  3. -- Infinite Smooth Desert Terrain Generator :3
  4. -- PS: CloneTrooper1019 does not answer :{ what e v e r ? ? ?
  5. -- PPS: You can disable cavesRarity by putting 0 , it sometimes looks weird :/
  6. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  7. -- CONFIGURATION:
  8. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  9.  
  10. baseHeight = 4
  11. -- ^ The main height factor for the terrain.
  12.  
  13. mountainHeight = 3
  14. -- ^ How tall should mountains be relative to the baseHeight of the terrain
  15.  
  16. mountainMaterialWeight = -0.5
  17. -- ^ The chance that a dune chunk gets sandstone instead of limestone in it
  18. --    Should be a number between 0 and 1
  19. --    0 = only rock, 1 = only slate, 0.5 = half n half
  20. cavesRarity = .4
  21. -- Holes in the terrain
  22.  
  23. chunkScale = 3
  24. -- ^ The grid scale for terrain generation.
  25.  
  26. renderDist = 120
  27. -- ^ The length/width of chunks in voxels that should be around the player at all times
  28.  
  29. xScale = 50
  30. -- ^ How much we should strech the X scale of the generation noise
  31.  
  32. zScale = 50
  33. -- ^ How much we should strech the Z scale of the generation noise
  34.  
  35. waterLevel = -0.4
  36. -- ^ Determines if we should generate ponds if the height level goes below this
  37. --    Should be a number between -1 and 1
  38. --    -1 = no water, 0 = all grass levels are filled with water, 1 = The entire map is flooded with water (Except for tall mountains)
  39.  
  40. seed = math.random()
  41. -- ^ Seed for determining the height map of the terrain.
  42. --    By default its random.
  43. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  44.  
  45. local chunks = {}
  46.  
  47. function chunkExists(chunkX,chunkZ)
  48.     if not chunks[chunkX] then
  49.         chunks[chunkX] = {}
  50.     end
  51.     return chunks[chunkX][chunkZ]
  52. end
  53.  
  54. function fillSmoothBlock(x,z,begY,endY,material)
  55.     local location = CFrame.new(x*4+2, (begY+endY)*4/2, z*4+2)
  56.     local fill = Vector3.new(4, (endY-begY)*4, 4)
  57.     workspace.Terrain:FillBlock(location,fill,material)
  58. end
  59.  
  60. function mountLayer(x,heightY,z,material)
  61.     -- Fill in Lakes/Ponds
  62.     local waterFill = baseHeight * waterLevel
  63.     if heightY < waterFill then
  64.         material = Enum.Material.Sandstone -- Make the material sand.
  65.         fillSmoothBlock(x,z,heightY-1,waterFill,Enum.Material.Water) -- Fill some water in.
  66.     end
  67.     -- Fill in the main terrain.
  68.     fillSmoothBlock(x,z,-baseHeight,heightY,material)
  69. end
  70.  
  71. function makeChunk(chunkX,chunkZ)
  72.     local rootPos = Vector3.new(chunkX*chunkScale,0,chunkZ*chunkScale)
  73.     chunks[chunkX][chunkZ] = true -- Acknowledge the chunk's existance.
  74.     for x = 0,chunkScale-1 do
  75.         for z = 0,chunkScale-1 do
  76.             local cx = (chunkX*chunkScale) + x
  77.             local cz = (chunkZ*chunkScale) + z
  78.             local noise = math.noise(seed,cx/xScale,cz/zScale)
  79.             local isMountain = (noise > 0)
  80.             local material,materialScale do
  81.                 if not isMountain then
  82.                     material = Enum.Material.Sand
  83.                     materialScale = 1
  84.                 else
  85.                     materialScale = mountainHeight
  86.                     if math.random() > mountainMaterialWeight then
  87.                         material = Enum.Material.Limestone
  88.                     else
  89.                         if math.random() > cavesRarity then
  90.                             material = Enum.Material.Air
  91.                         else
  92.                             material = Enum.Material.Sandstone
  93.                         end
  94.                     end
  95.                 end
  96.             end
  97.             local cy = noise*baseHeight*materialScale
  98.             mountLayer(cx,cy,cz,material)
  99.         end
  100.     end
  101. end
  102.  
  103. function doAreaFill(location)
  104.     local chunkX,chunkZ = math.floor(location.X/4/chunkScale),math.floor(location.Z/4/chunkScale)
  105.     local range = math.max(1,renderDist/chunkScale)
  106.     for x = -range,range do
  107.         for z = -range,range do
  108.             local cx,cz = chunkX + x,chunkZ + z
  109.             if not chunkExists(cx,cz) then
  110.                 makeChunk(cx,cz)
  111.             end
  112.         end
  113.     end
  114. end
  115.  
  116. while true do
  117.     for _,v in pairs(game.Players:GetPlayers()) do
  118.         spawn(function ()
  119.             local char = v.Character
  120.             if char then
  121.                 local torso = char:findFirstChild("Torso")
  122.                 if torso then
  123.                     doAreaFill(torso.Position)
  124.                 end
  125.             end
  126.         end)
  127.     end
  128.     wait(1)
  129. end
  130. print(1+1)
  131. for i = 1, 4000 do -- Dont touch 1. For more cacti, change 400 to the amount of cacti.
  132.     local part = Instance.new("Part", workspace) --The part itself
  133.     part.Anchored = true -- Anti moving
  134. part.Size = Vector3.new(math.random(2), math.random(30), math.random(2)) -- Size of cactis . Working so that X and Z are equal)
  135. part.CFrame = CFrame.new(math.random(-1000, 1000), part.Size.Y/2, math.random(-1000, 1000)) -- Position limits
  136. part.BrickColor = BrickColor.new(323) -- Color (ArtichokeZ lul)
  137. part.Material = "Grass" -- Cacti material.
  138. part.CanCollide = 0
  139. wait(3)
  140. part.CanCollide = 1
  141. print("Hey kids, i'm Shyvha and i've done this nice scripts. Btw the pastebin link right here is like not my pastebin ,exept if the code is 2meKk5Ry.. Be sure to check out my pastebin,its Shyvha... And,don't skid shit around there, kay? thanks maam.")
  142. print("Hey,upgraded this to 1.1.3, as cactis are in :D Enjoy and don't skid shit around ! thanks maam")
  143. wait(5)
  144. print("did u even readed this lolz")
  145. end
  146. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement