Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- -- Shyvha, 2017. Partially based off @CloneTrooper1019, 2015
- -- Infinite Smooth Desert Terrain Generator :3
- -- PS: CloneTrooper1019 does not answer :{ what e v e r ? ? ?
- -- PPS: You can disable cavesRarity by putting 0 , it sometimes looks weird :/
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- -- CONFIGURATION:
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- baseHeight = 4
- -- ^ The main height factor for the terrain.
- mountainHeight = 3
- -- ^ How tall should mountains be relative to the baseHeight of the terrain
- mountainMaterialWeight = -0.5
- -- ^ The chance that a dune chunk gets sandstone instead of limestone in it
- -- Should be a number between 0 and 1
- -- 0 = only rock, 1 = only slate, 0.5 = half n half
- cavesRarity = .4
- -- Holes in the terrain
- chunkScale = 3
- -- ^ The grid scale for terrain generation.
- renderDist = 120
- -- ^ The length/width of chunks in voxels that should be around the player at all times
- xScale = 50
- -- ^ How much we should strech the X scale of the generation noise
- zScale = 50
- -- ^ How much we should strech the Z scale of the generation noise
- waterLevel = -0.4
- -- ^ Determines if we should generate ponds if the height level goes below this
- -- Should be a number between -1 and 1
- -- -1 = no water, 0 = all grass levels are filled with water, 1 = The entire map is flooded with water (Except for tall mountains)
- seed = math.random()
- -- ^ Seed for determining the height map of the terrain.
- -- By default its random.
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- local chunks = {}
- function chunkExists(chunkX,chunkZ)
- if not chunks[chunkX] then
- chunks[chunkX] = {}
- end
- return chunks[chunkX][chunkZ]
- end
- function fillSmoothBlock(x,z,begY,endY,material)
- local location = CFrame.new(x*4+2, (begY+endY)*4/2, z*4+2)
- local fill = Vector3.new(4, (endY-begY)*4, 4)
- workspace.Terrain:FillBlock(location,fill,material)
- end
- function mountLayer(x,heightY,z,material)
- -- Fill in Lakes/Ponds
- local waterFill = baseHeight * waterLevel
- if heightY < waterFill then
- material = Enum.Material.Sandstone -- Make the material sand.
- fillSmoothBlock(x,z,heightY-1,waterFill,Enum.Material.Water) -- Fill some water in.
- end
- -- Fill in the main terrain.
- fillSmoothBlock(x,z,-baseHeight,heightY,material)
- end
- function makeChunk(chunkX,chunkZ)
- local rootPos = Vector3.new(chunkX*chunkScale,0,chunkZ*chunkScale)
- chunks[chunkX][chunkZ] = true -- Acknowledge the chunk's existance.
- for x = 0,chunkScale-1 do
- for z = 0,chunkScale-1 do
- local cx = (chunkX*chunkScale) + x
- local cz = (chunkZ*chunkScale) + z
- local noise = math.noise(seed,cx/xScale,cz/zScale)
- local isMountain = (noise > 0)
- local material,materialScale do
- if not isMountain then
- material = Enum.Material.Sand
- materialScale = 1
- else
- materialScale = mountainHeight
- if math.random() > mountainMaterialWeight then
- material = Enum.Material.Limestone
- else
- if math.random() > cavesRarity then
- material = Enum.Material.Air
- else
- material = Enum.Material.Sandstone
- end
- end
- end
- end
- local cy = noise*baseHeight*materialScale
- mountLayer(cx,cy,cz,material)
- end
- end
- end
- function doAreaFill(location)
- local chunkX,chunkZ = math.floor(location.X/4/chunkScale),math.floor(location.Z/4/chunkScale)
- local range = math.max(1,renderDist/chunkScale)
- for x = -range,range do
- for z = -range,range do
- local cx,cz = chunkX + x,chunkZ + z
- if not chunkExists(cx,cz) then
- makeChunk(cx,cz)
- end
- end
- end
- end
- while true do
- for _,v in pairs(game.Players:GetPlayers()) do
- spawn(function ()
- local char = v.Character
- if char then
- local torso = char:findFirstChild("Torso")
- if torso then
- doAreaFill(torso.Position)
- end
- end
- end)
- end
- wait(1)
- end
- print(1+1)
- for i = 1, 4000 do -- Dont touch 1. For more cacti, change 400 to the amount of cacti.
- local part = Instance.new("Part", workspace) --The part itself
- part.Anchored = true -- Anti moving
- part.Size = Vector3.new(math.random(2), math.random(30), math.random(2)) -- Size of cactis . Working so that X and Z are equal)
- part.CFrame = CFrame.new(math.random(-1000, 1000), part.Size.Y/2, math.random(-1000, 1000)) -- Position limits
- part.BrickColor = BrickColor.new(323) -- Color (ArtichokeZ lul)
- part.Material = "Grass" -- Cacti material.
- part.CanCollide = 0
- wait(3)
- part.CanCollide = 1
- 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.")
- print("Hey,upgraded this to 1.1.3, as cactis are in :D Enjoy and don't skid shit around ! thanks maam")
- wait(5)
- print("did u even readed this lolz")
- end
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement