Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- -- Shyvha and @CloneTrooper1019, 2015
- -- Infinite Smooth Terrain Generator :3
- -- PS: I'm sorry that I didnt asked CloneTrooper1019 to edit the scripts, I might do it A S A P ! :wink:
- -- 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.01
- -- ^ 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
- cavesRarity = .2
- -- Holes in the terrain
- chunkScale = 3
- -- ^ The grid scale for terrain generation.
- renderDist = 45
- -- ^ 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.5
- -- ^ 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.
- baseHeight2 = 10
- -- ^ The main height factor for the terrain.
- mountainHeight2 = 12
- -- ^ How tall should mountains be relative to the baseHeight of the terrain
- mountainMaterialWeight2 = 0.2
- -- ^ 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
- canyonMaterialDensity2 = 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
- chunkScale2 = 3
- -- ^ The grid scale for terrain generation.
- renderDist2 = 45
- -- ^ The length/width of chunks in voxels that should be around the player at all times
- xScale2 = 30
- -- ^ How much we should strech the X scale of the generation noise
- zScale2 = 30
- -- ^ How much we should strech the Z scale of the generation noise
- waterLevel2 = -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)
- seed2 = math.random()
- -- ^ Seed for determining the height map of the terrain.
- -- By default its random.
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- repeat
- while wait(10) do
- 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
- break
- end
- while wait(20) do
- 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 = baseHeight2 * waterLevel2
- 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,-baseHeight2,heightY,material)
- end
- function makeChunk(chunkX,chunkZ)
- local rootPos = Vector3.new(chunkX*chunkScale2,0,chunkZ*chunkScale2)
- chunks[chunkX][chunkZ] = true -- Acknowledge the chunk's existance.
- for x = 0,chunkScale2-1 do
- for z = 0,chunkScale2-1 do
- local cx = (chunkX*chunkScale2) + x
- local cz = (chunkZ*chunkScale2) + z
- local noise = math.noise(seed2,cx/xScale2,cz/zScale2)
- local isMountain = (noise > 0)
- local material,materialScale do
- if not isMountain then
- material = Enum.Material.Sand
- materialScale = 1
- else
- materialScale = mountainHeight
- if math.random() > mountainMaterialWeight2 then
- material = Enum.Material.Sandstone
- else
- if math.random() > canyonMaterialDensity2 then
- material = Enum.Material.Limestone
- else
- material = Enum.Material.Rock
- end
- end
- end
- end
- local cy = noise*baseHeight2*materialScale
- mountLayer(cx,cy,cz,material)
- end
- end
- end
- function doAreaFill(location)
- local chunkX,chunkZ = math.floor(location.X/4/chunkScale2),math.floor(location.Z/4/chunkScale2)
- local range = math.max(1,renderDist/chunkScale2)
- 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
- 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
- until false
- ---------------------------------------------------------------------------------------------------------------------------------------
- --Thanks for CloneTrooper1019 for the main script
- --I'm working on the "end" of the "while wait(120)"
- --if you have a solution message me on roblox (Follow me , then message me the answer and where to close it, i'll find the place with ---ctrl+f.
- --Keep Persevering.
- --WIP
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement