Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local LastPosition = CFrame.new(-70, 0, -40)
- local x, y, z = -3, -9, -3
- local x1, y1, z1 = 3, -7, 3
- local x2, y2, z2 = x, y, z
- local t1 = true
- while t1 do
- for i = 1, 10 do
- if y2 > y1 then t1 = false break end
- if z2 > z1 then z2 = z y2 = y2 + 1 end
- local part = Instance.new("Part", workspace)
- part.CanCollide = false
- part.Size = Vector3.new(2000, 5, 2000)
- part.CFrame = CFrame.new(x2*part.Size.X, y2*-part.Size.Y+1.5, z2*part.Size.Z)
- part.Anchored = true
- part.Transparency = 0.2
- part.Reflectance = 0.6
- part.BrickColor = BrickColor.new("Deep blue")
- part.BackSurface = "SmoothNoOutlines"
- part.FrontSurface = "SmoothNoOutlines"
- part.BottomSurface = "SmoothNoOutlines"
- part.TopSurface = "SmoothNoOutlines"
- part.RightSurface = "SmoothNoOutlines"
- part.LeftSurface = "SmoothNoOutlines"
- part.Material = "SmoothPlastic"
- if x2 > x1 then x2 = x z2 = z2 + 1 end
- x2 = x2 + 1
- end
- wait()
- end
- local Hills = {
- --Hill1 = {
- -- Position = CFrame.new(-200, 0, -100);
- -- Range = 100;
- -- Height = 10;
- -- Color = BrickColor.new("Medium stone gray");
- -- TreeSpawn = false
- --};
- --[[
- Hill2 = {
- Position = Vector3.new(-200, 0, 200);
- Range = 250;
- Height = 10;
- Color = BrickColor.new("Forest green");
- };
- Hill3 = {
- Position = Vector3.new(-200, 0, -200);
- Range = 200;
- Height = 10;
- Color = BrickColor.new("Forest green");
- };
- Hill4 = {
- Position = Vector3.new(200, 0, -200);
- Range = 150;
- Height = 10;
- Color = BrickColor.new("Forest green");
- }]]
- }
- local treemodel = Instance.new("Model", game.Lighting)
- local p = Instance.new("Part", treemodel)
- local treethickness = math.random(2, 6)
- p.BrickColor = BrickColor.new("Dark orange")
- p.Size = Vector3.new(treethickness, math.random(4, 20), treethickness)
- p.CFrame = CFrame.new(0, 0, 0)
- p.Anchored = true
- p.Name = "stump"
- local p1 = Instance.new("Part", treemodel)
- local leavesize = math.random(4, 30)
- p1.BrickColor = BrickColor.new("Bright green")
- p1.Size = Vector3.new(treethickness + leavesize, leavesize/8, treethickness + leavesize)
- p1.CFrame = CFrame.new(0, p.Size.Y/2 + p1.Size.Y/2, 0)
- p1.Anchored = true
- p1.Name = "bottom_leave"
- local p2 = Instance.new("Part", treemodel)
- p2.BrickColor = BrickColor.new("Bright green")
- p2.Size = Vector3.new(treethickness + leavesize/2, leavesize/8, treethickness + leavesize/2)
- p2.CFrame = CFrame.new(0, p.Size.Y/2 + p1.Size.Y + p2.Size.Y/2, 0)
- p2.Anchored = true
- p2.Name = "top_leave"
- local totaltreeheight = p.Size.Y + p1.Size.Y + p2.Size.Y
- function minimedrandom(n1min, n1, n2min, n2)
- local t = true
- local r = 0
- while t do
- r = math.random(n1, n2)
- if r < n1min and r < 0 then
- t = false
- end
- if r > n2min and r > 0 then
- t = false
- end
- end
- return r
- end
- function block1insideblock2(s1, v1, s2, v2) --idk how to call this pff
- local block1 = {
- Size = s1;
- Position = v1
- }
- local block2 = {
- Size = s2;
- Position = v2
- }
- --check if block1 is inside block2
- if block1.Position == nil then error("Position at argument #1 is nil") end
- if block2.Position == nil then error("Position at argument #3 is nil") end
- if block1.Size == nil then error("Size at argument #2 is nil") end
- if block2.Size == nil then error("Size at argument #4 is nil") end
- if block1.Position.X >= block2.Position.X - block2.Size.X and
- block1.Position.X <= block2.Position.X + block2.Size.X and
- block1.Position.Z >= block2.Position.Z - block2.Size.Z and
- block1.Position.Z <= block2.Position.Z + block2.Size.Z
- then
- return true
- end
- return false
- end
- local tp = true
- local parts = {}
- for i = 1, math.random(50, 100) do
- local newhill = {
- Position = CFrame.new(math.random(-3000, 3000), 0, math.random(-3000, 3000));
- Range = math.random(100, 300);
- Height = math.random(1, 6);
- Color = BrickColor.new("Dark green");
- DirtColor = BrickColor.new("Rust");
- StoneColor = BrickColor.new("Dark stone grey");
- TreeSpawn = true;
- StoneLand = false
- }
- if math.random(1, newhill.Height + 1) == 1 then
- newhill.StoneLand = true
- newhill.TreeSpawn = false
- newhill.Color = newhill.StoneColor
- newhill.DirtColor = newhill.StoneColor
- end
- table.insert(Hills, 0, newhill)
- end
- local max = 1000
- local chunks = 0
- function MagXZ(x, z)
- return x + z
- end
- while wait() do
- function generateblock()
- local P
- if tp == true then
- P = Instance.new("SpawnLocation", workspace)
- else
- P = Instance.new("Part", workspace)
- end
- P.Size = Vector3.new(minimedrandom(-80, -30, 30, 80), 1, minimedrandom(-80, -30, 30, 80))
- P.CFrame = CFrame.new(math.random(-1, 1)*P.Size.X + LastPosition.X, 50, math.random(-1, 1)*P.Size.Z + LastPosition.Z)
- P.Name = "GPart"
- --[[for _,p in pairs(parts) do
- print(p.Position.X .. ", " .. p.Position.Y .. ", " .. p.Position.Z)
- local check = true
- if p.Position == nil and p.Size == nil then print("nope nil") check = false end
- if check then
- if block1insideblock2(p.Size, p.Position, P.Size, P.Position) then
- print("A block was way too much inside another block and was deleted.")
- P:Destroy()
- return
- end
- end
- end]]
- --if P:GetConnectedParts() then
- -- if P:GetConnectedParts()[1].Name ~= "GPart" then
- -- P:Destroy()
- -- return
- -- end
- --end
- if math.abs(MagXZ(P.Position.X, P.Position.Z) - MagXZ(LastPosition.X, LastPosition.Z)) >= (P.Size.X + P.Size.Z) then
- P:Destroy()
- return
- end
- local oldpos = P.CFrame
- local height = 1
- local treescanspawn = true
- local dirtcolor = BrickColor.new("Rust")
- P.BrickColor = BrickColor.new("Dark green")
- for _,h in pairs(Hills) do
- local closeness = -(P.CFrame.p - h.Position.p).magnitude + h.Range
- --local height2 = (Vector3.new(h.Position.X - P.Position.X, 0, h.Position.Z - P.Position.Z).Magnitude/15) - 20
- --if height2 < 0 then height2 = 0 end
- if h.Range > closeness and closeness > 0 then
- height = math.min(h.Height, height) + closeness
- P.BrickColor = h.Color
- dirtcolor = h.DirtColor
- if h.TreeSpawn == false then
- treescanspawn = false
- end
- --print("SUCCESS closeness:" .. closeness)
- else
- --warn("FAIL closeness:" .. closeness)
- end
- end
- height = height + 100-math.noise(P.CFrame.p.X/10, 6421.1761, P.CFrame.p.Z/10)*30
- print(height)
- --print(height)
- --Add dirt
- local PD = Instance.new("Part", workspace)
- PD.Size = Vector3.new(P.Size.X - (math.random(1, 50)/100), height - 4, P.Size.Z - (math.random(1, 50)/100))
- PD.CFrame = CFrame.new(P.Position.X, 50, P.Position.Z)
- PD.BrickColor = dirtcolor
- PD.Anchored = true
- PD.Name = "Dirt"
- --Add grass on top
- P.Size = Vector3.new(P.Size.X, 3, P.Size.Z)
- P.CFrame = CFrame.new(oldpos.X, oldpos.Y + ((height-4)/2), oldpos.Z)
- P.Anchored = true
- P.Name = "Grass"
- --Add sand
- local PS = Instance.new("Part", workspace)
- PS.Size = Vector3.new(P.Size.X + 4, 100, P.Size.Z + 4)
- PS.CFrame = CFrame.new(P.Position.X, -0.5, P.Position.Z)
- PS.BrickColor = BrickColor.new("Cool yellow")
- PS.Anchored = true
- PS.Name = "Sand"
- --Add underbase
- local PB = Instance.new("Part", workspace)
- PB.Size = Vector3.new(PS.Size.X + 4, PS.Size.Y - 2, PS.Size.Z + 4)
- PB.CFrame = CFrame.new(PS.Position.X, -0.5, PS.Position.Z)
- PB.BrickColor = BrickColor.new("Dark stone grey")
- PB.Anchored = true
- PB.Name = "UnderBase"
- if tp == true then
- tp = false
- for _,p in pairs(workspace:GetChildren()) do
- if game.Players:FindFirstChild(p.Name) then
- p:MoveTo(Vector3.new(P.Position.X + math.random(-P.Size.X/2, P.Size.X/2), P.Position.Y + 5, P.Position.Z + math.random(-P.Size.Z/2, P.Size.Z/2)))
- end
- end
- end
- if treescanspawn == true and math.random(1, 6) == 6 then
- for i = 1, math.random(1, 4) do
- local tree = treemodel:Clone()
- tree.Parent = workspace
- tree.stump.CFrame = CFrame.new(P.Position.X + math.random(-P.Size.X/2, P.Size.X/2), P.Position.Y + P.Size.Y/2 + tree.stump.Size.Y/2, P.Position.Z + math.random(-P.Size.Z/2, P.Size.Z/2))
- tree.bottom_leave.CFrame = CFrame.new(tree.stump.Position.X, tree.stump.Position.Y + tree.stump.Size.Y/2 + tree.bottom_leave.Size.Y/2, tree.stump.Position.Z)
- tree.top_leave.CFrame = CFrame.new(tree.stump.Position.X, tree.bottom_leave.Position.Y + tree.bottom_leave.Size.Y/2 + tree.top_leave.Size.Y/2, tree.stump.Position.Z)
- tree.stump.Parent = workspace
- tree.bottom_leave.Parent = workspace
- tree.top_leave.Parent = workspace
- tree:Destroy()
- end
- end
- table.insert(parts, 0, {
- P.Size;
- P.Position
- })
- --print(P.Position.Z .. ", " .. P.Position.Y .. ", " .. P.Position.Z)
- LastPosition = P.Position
- print(math.noise(LastPosition.X - P.Position.X/100, LastPosition.Y - P.Position.Y/100, LastPosition.Z - P.Position.Z/100))
- end
- generateblock()
- if chunks >= max then break end
- chunks = chunks + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement