Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- -- @CloneTrooper1019, 2015 , Shyvha , 2017
- -- Infinite Smooth Canyon Generator :3
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- -- CONFIGURATION:
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- baseHeight = 10
- -- ^ The main height factor for the terrain.
- mountainHeight = 12
- -- ^ How tall should mountains be relative to the baseHeight of the terrain
- mountainMaterialWeight = 0.4
- -- ^ The chance that a mountain terrain chunk will generate using slate rather than rock
- -- Should be a number between 0 and 1
- -- 0 = only rock, 1 = only slate, 0.5 = half n half
- canyonMaterialDensity = 0.1
- -- ^ The limestone rarity
- -- 0 = No Limestone at all , 1 = Only limestone (NOT RECOMMANDED) , 0.2 = small bumps (Realist)
- -- Note that limestone is not very different from sand, but it adds some realism
- chunkScale = 4
- -- ^ The grid scale for terrain generation.
- renderDist = 90
- -- ^ The length/width of chunks in voxels that should be around the player at all times
- xScale = 30
- -- ^ How much we should strech the X scale of the generation noise
- zScale = 30
- -- ^ How much we should strech the Z scale of the generation noise
- waterLevel = -0.9
- -- ^ 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.Sand -- Make the material sand.
- fillSmoothBlock(x,z,heightY-2,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.Sandstone
- else
- if math.random() > canyonMaterialDensity then
- material = Enum.Material.Basalt
- else
- material = Enum.Material.Rock
- 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
- ---------------------------------------------------------------------------------------------------------------------------------------
- --Thanks for CloneTrooper1019 for the main script
- --I scripted the sand to be up there.
- --WIP
Add Comment
Please, Sign In to add comment