Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --GENERATOR
- --Biomas: grama, deserto
- changeInVal = 300 -- quanto mais, menos grama tem
- function generate(plr, base, seed)
- print(seed)
- math.randomseed(seed)
- local blocks = {}
- local startingBiome = math.random(1,2)
- local currentBlock = nil -- Seta o inicial
- local grassCount = 0
- local sandCount = 0
- currentBlock = game.ReplicatedStorage.Blocks.Water:Clone()
- currentBlock.Parent = base.Landscape
- currentBlock.Position = base.Colony.Sig.Position
- blocks[0] = currentBlock
- local xVar = 1
- local zVar = 0
- while zVar < 285 do -- geração inicial
- while xVar < 266 do
- if zVar > 0 then
- startingBiome = math.random(1,changeInVal)
- local tableXMinus = (xVar + (zVar * 266)) - 1
- local tableZMinus = (xVar + (zVar * 266)) - 266
- if xVar == 0 then
- if blocks[tableZMinus].Name == "Grass" then
- if startingBiome == 1 then
- currentBlock = game.ReplicatedStorage.Blocks.Water:Clone()
- else
- currentBlock = game.ReplicatedStorage.Blocks.Grass:Clone()
- end
- end
- if blocks[tableZMinus].Name == "Water" then
- if startingBiome == 1 then
- currentBlock = game.ReplicatedStorage.Blocks.Grass:Clone()
- else
- currentBlock = game.ReplicatedStorage.Blocks.Water:Clone()
- end
- end
- else
- if blocks[tableXMinus].Name == blocks[tableZMinus].Name then
- if blocks[tableXMinus].Name == "Grass" then
- if startingBiome == 1 then
- currentBlock = game.ReplicatedStorage.Blocks.Water:Clone()
- else
- currentBlock = game.ReplicatedStorage.Blocks.Grass:Clone()
- end
- end
- if blocks[tableXMinus].Name == "Water" then
- if startingBiome == 1 then
- currentBlock = game.ReplicatedStorage.Blocks.Grass:Clone()
- else
- currentBlock = game.ReplicatedStorage.Blocks.Water:Clone()
- end
- end
- else
- startingBiome = math.random(1,100)
- if startingBiome < 50 then
- currentBlock = game.ReplicatedStorage.Blocks.Grass:Clone()
- end
- if startingBiome > 50 then
- currentBlock = game.ReplicatedStorage.Blocks.Water:Clone()
- end
- if startingBiome == 50 then
- currentBlock = game.ReplicatedStorage.Blocks.Grass:Clone()
- end
- end
- end
- else
- startingBiome = math.random(1, changeInVal)
- local mathHandler = (xVar + (zVar * 266)) - 1
- if blocks[mathHandler].Name == "Grass" then
- if startingBiome == 1 then
- currentBlock = game.ReplicatedStorage.Blocks.Water:Clone()
- else
- currentBlock = game.ReplicatedStorage.Blocks.Grass:Clone()
- end
- end
- if blocks[mathHandler].Name == "Water" then
- if startingBiome == 1 then
- currentBlock = game.ReplicatedStorage.Blocks.Grass:Clone()
- else
- currentBlock = game.ReplicatedStorage.Blocks.Water:Clone()
- end
- end
- end
- currentBlock.Parent = base.Landscape
- if currentBlock.Name == "Grass" then
- currentBlock.Position = base.Colony.Sig.Position - Vector3.new(xVar, 0, zVar) + Vector3.new(0, 0.2, 0)
- else
- currentBlock.Position = base.Colony.Sig.Position - Vector3.new(xVar, 0, zVar)
- end
- local tableToEdit = xVar + (zVar * 266)
- blocks[tableToEdit] = currentBlock
- if currentBlock.Name == "Grass" then
- grassCount = grassCount + 1
- end
- if currentBlock.Name == "Water" then
- sandCount = sandCount + 1
- end
- xVar = xVar + 1
- end
- xVar = 0
- zVar = zVar + 1
- wait(0.01)
- end
- zVar = 0
- xVar = 0
- while xVar < 266 do
- blocks[285 * 266 + xVar] = plr
- xVar = xVar + 1
- end
- xVar = 0
- --fixes #1
- while zVar < 285 do
- while xVar < 266 do
- if xVar > 0 and xVar < 266 then
- if zVar > 0 and zVar < 285 then
- local tableXMinus = (xVar + (zVar * 266)) - 1
- local tableZMinus = (xVar + (zVar * 266)) - 266
- local tableXPlus = (xVar + (zVar * 266)) + 1
- local tableZPlus = (xVar + (zVar * 266)) + 266
- local tableNow = xVar + (zVar * 266)
- if blocks[tableNow].Name == "Grass" then
- if blocks[tableXMinus].Name == "Water" and blocks[tableXPlus].Name == "Water" and blocks[tableZMinus].Name == "Water" and blocks[tableZPlus].Name == "Water" then
- blocks[tableNow]:Destroy()
- currentBlock = game.ReplicatedStorage.Blocks.Water:Clone()
- currentBlock.Parent = base.Landscape
- currentBlock.Position = base.Colony.Sig.Position - Vector3.new(xVar, 0, zVar)
- local tableToEdit = xVar + (zVar * 266)
- blocks[tableToEdit] = currentBlock
- end
- else
- if blocks[tableXMinus].Name == "Grass" and blocks[tableXPlus].Name == "Grass" and blocks[tableZMinus].Name == "Grass" and blocks[tableZPlus].Name == "Grass" then
- blocks[tableNow]:Destroy()
- currentBlock = game.ReplicatedStorage.Blocks.Grass:Clone()
- currentBlock.Parent = base.Landscape
- currentBlock.Position = base.Colony.Sig.Position - Vector3.new(xVar, 0, zVar) + Vector3.new(0, 0.2, 0)
- local tableToEdit = xVar + (zVar * 266)
- blocks[tableToEdit] = currentBlock
- end
- end
- if xVar > 0 and xVar < 266 then
- if zVar > 0 and zVar < 285 then
- if blocks[tableXMinus].Name == "Water" or blocks[tableZMinus].Name == "Water" or blocks[tableXPlus].Name == "Water" or blocks[tableZPlus].Name == "Water" then
- if blocks[tableNow].Name == "Grass" then
- blocks[tableNow]:Destroy()
- currentBlock = game.ReplicatedStorage.Blocks.Sand:Clone()
- currentBlock.Parent = base.Landscape
- currentBlock.Position = base.Colony.Sig.Position - Vector3.new(xVar, 0, zVar) + Vector3.new(0, 0.1, 0)
- blocks[tableNow] = currentBlock
- end
- end
- end
- end
- end
- if xVar == 0 or xVar == 266 or zVar == 285 then
- if blocks[xVar + (zVar * 266)].Name == "Grass" then
- blocks[xVar + (zVar * 266)]:Destroy()
- currentBlock = game.ReplicatedStorage.Blocks.Sand:Clone()
- currentBlock.Parent = base.Landscape
- currentBlock.Position = base.Colony.Sig.Position - Vector3.new(xVar, 0, zVar) + Vector3.new(0, 0.1, 0)
- blocks[xVar + (zVar * 266)] = currentBlock
- end
- end
- end
- xVar = xVar + 1
- end
- zVar = zVar + 1
- wait(0.01)
- xVar = 0
- end
- xVar = 0
- zVar = 0
- local done = false
- local first = true
- while not done do
- if blocks[xVar + (zVar * 266)].Name == "Grass" then
- blocks[xVar + (zVar * 266)]:Destroy()
- currentBlock = game.ReplicatedStorage.Blocks.Sand:Clone()
- currentBlock.Parent = base.Landscape
- currentBlock.Position = base.Colony.Sig.Position - Vector3.new(xVar, 0.1, zVar)
- blocks[xVar + (zVar * 266)] = currentBlock
- end
- if first and xVar == 266 then
- first = false
- xVar = 0
- zVar = 284
- end
- if not first then
- if xVar == 266 then
- done = true
- end
- end
- xVar = xVar + 1
- end
- print("Gerado!")
- end
- game.ReplicatedStorage.Events.GenerateTerrain.Event:Connect(generate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement