Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _G.ChunkSize = 16
- _G.RenderDist = 1
- _G.BlockSize = 3
- _G.MaxTerrainHeight = 64
- _G.OptimizedHeight = true
- _G.Chunks = {}
- _G.NoiseScale = 30
- _G.Amplitude = 20
- _G.Octaves = 1
- _G.Frequency = 1
- _G.Gain = 1
- _G.CoGain = 1
- _G.Lacunarity = 2
- _G.CoLacunarity = 1
- _G.MaxDensity = 20
- _G.Seed = math.random()
- math.randomseed(_G.Seed % tick())
- _G.Seed = math.random()
- local f = nil
- if _G.RenderDist < 1 then
- _G.RenderDist = 1
- end
- function CheckChunk(x, z)
- if _G.Chunks[x] == nil then
- _G.Chunks[x] = {}
- end
- return _G.Chunks[x][z]
- end
- function RoundTo(a, b)
- return a - (a % b)
- end
- function Noise(x, y, z)
- local Xnoise = 0
- local Ynoise = 0
- local Znoise = 0
- local Amp = _G.Amplitude
- local Fre = _G.Frequency
- Ynoise = math.noise(Fre * (x / _G.NoiseScale), Fre * (z / _G.NoiseScale), _G.Seed) * Amp
- for i = 0, _G.Octaves do
- Xnoise = Xnoise + math.noise(y / _G.NoiseScale, z / _G.NoiseScale, _G.Seed) * Amp
- Znoise = Znoise + math.noise(x / _G.NoiseScale, y / _G.NoiseScale, _G.Seed) * Amp
- Amp = Amp * _G.Gain
- Amp = Amp / _G.Cogain
- Fre = Fre * _G.Lacunarity
- Fre = Fre / _G.CoLacunarity
- end
- return Xnoise + Ynoise + Znoise - y
- end
- function MakeChunk(x, z)
- local Thread = coroutine.create(function()
- for xi = -_G.ChunkSize / _G.BlockSize, _G.ChunkSize / _G.BlockSize do
- for zi = -_G.ChunkSize / _G.BlockSize, _G.ChunkSize / _G.BlockSize do
- if _G.OptimizedHeight == false then
- for yi = -_G.MaxTerrainHeight, _G.MaxTerrainHeight do
- if Noise(xi, yi, zi) < _G.MaxDensity then
- end
- end
- elseif _G.OptimizedHeight == true then
- for yi = -_G.MaxTerrainHeight, _G.MaxTerrainHeight do
- if Noise(xi, yi, zi) < _G.MaxDensity then
- end
- end
- end
- end
- end
- end)
- coroutine.resume(Thread)
- end
- function CheckPos(x, z)
- local Thread = coroutine.create(function()
- local ChunkX = RoundTo(x, _G.ChunkSize) / _G.ChunkSize
- local ChunkZ = RoundTo(z, _G.ChunkSize) / _G.ChunkSize
- if not CheckChunk(ChunkX, ChunkZ) then
- for xi = -_G.RenderDist, _G.RenderDist do
- for zi = -_G.RenderDist, _G.RenderDist do
- local ChunkX = RoundTo(x, _G.ChunkSize) / _G.ChunkSize + xi
- local ChunkZ = RoundTo(z, _G.ChunkSize) / _G.ChunkSize + zi
- if not CheckChunk(ChunkX, ChunkZ) then
- _G.Chunks[ChunkX][ChunkZ] = true
- end
- if f == nil then
- f = ChunkX.." : "..ChunkZ
- end
- if f == ChunkX.." : "..ChunkZ then
- print("Same!")
- end
- end
- end
- end
- end)
- coroutine.resume(Thread)
- end
- spawn(function()
- while true do
- wait(1)
- --print("hh")
- for i, v in pairs(game:GetService("Players"):GetChildren()) do
- local C = nil
- local HRP = nil
- pcall(function()
- if v.Character then
- C = v.Character
- else
- C = nil
- end
- end)
- if C ~= nil then
- pcall(function()
- if C:FindFirstChild("HumanoidRootPart") then
- HRP = C:FindFirstChild("HumanoidRootPart")
- else
- HRP = nil
- end
- end)
- end
- if HRP ~= nil then
- CheckPos(HRP.Position.X, HRP.Position.Z)
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement