User:Mindraker/Terrain

From Legacy Roblox Wiki
Jump to navigationJump to search

For the current page on terrains, please see Terrain Generation

Mathematical Slopes

Mathematical Slopes
for i = 1,100, .1 do

a=math.random(1,100)
b=math.random(1,100)
c=math.random(1,100)

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(100*math.sin(a), (100*math.sin(a)*math.cos(c))+100, 100*math.cos(c)))
p.Size = Vector3.new(8,8,8)
p.Anchored = true
p.Color = Color3.new(1)
p.BottomSurface = "Smooth"
p.TopSurface = "Smooth"
p.Parent = game.Workspace

q = Instance.new("SpecialMesh")
q.MeshType = "Sphere"
q.Parent = p

end

Pyramid script (with flat bottom)

x=1
y=1

for i = 50, 1, -1 do

x=i
y=(50-x)
z=y

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(1,i,1))
p.Size = Vector3.new(y,x,z)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
--wait(1)

end

Bowl (for real)

A bowl/valley
for i = 1, 50, 1 do
p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(-5, i, -i)) 
p.Size = Vector3.new(i+i-1, 1, 1)
p.Anchored = true
p.Color = Color3.new(1)
p.formFactor="Symmetric"
p.Parent = game.Workspace
--wait(1)


q = Instance.new("Part")
q.CFrame = CFrame.new(Vector3.new(i-6, i, -1)) 
q.Size = Vector3.new(1, 1, i+i-1)
q.Anchored = true
q.Color = Color3.new(1)
q.formFactor="Symmetric"
q.Parent = game.Workspace
--wait(1)



r = Instance.new("Part")
r.CFrame = CFrame.new(Vector3.new(-5, i, i-2)) 
r.Size = Vector3.new(i+i-1, 1, 1)
r.Anchored = true
r.Color = Color3.new(1)
r.formFactor="Symmetric"
r.Parent = game.Workspace
--wait(1)


s = Instance.new("Part")
s.CFrame = CFrame.new(Vector3.new(-i-4, i, -1)) 
s.Size = Vector3.new(1, 1, i+i-1)
s.Anchored = true
s.Color = Color3.new(1)
s.formFactor="Symmetric"
s.Parent = game.Workspace
--wait(1)

end


bowl test

I was actually trying to get a valley script, and this is what happens when you don't pay attention to your math
for i = 1, 10, 1 do
p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(-5, i, -i)) 
p.Size = Vector3.new(i*i, 1, 1)
p.Anchored = true
p.Color = Color3.new(1)
p.formFactor="Symmetric"
p.Parent = game.Workspace
--wait(1)


q = Instance.new("Part")
q.CFrame = CFrame.new(Vector3.new(i-6, i, -1)) 
q.Size = Vector3.new(1, 1, i*i)
q.Anchored = true
q.Color = Color3.new(1)
q.formFactor="Symmetric"
q.Parent = game.Workspace
--wait(1)



r = Instance.new("Part")
r.CFrame = CFrame.new(Vector3.new(-5, i, i-2)) 
r.Size = Vector3.new(i*i, 1, 1)
r.Anchored = true
r.Color = Color3.new(1)
r.formFactor="Symmetric"
r.Parent = game.Workspace
--wait(1)


s = Instance.new("Part")
s.CFrame = CFrame.new(Vector3.new(-i-4, i, -1)) 
s.Size = Vector3.new(1, 1, i*i)
s.Anchored = true
s.Color = Color3.new(1)
s.formFactor="Symmetric"
s.Parent = game.Workspace
--wait(1)


end

Floors

See for information on floors and for information on the mathematical function used

floors
for j = 1, 10, .1 do

floor2 = (math.floor (j)*10)

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(j*10,floor2,1))
p.Size = Vector3.new(1,1,1)
p.Anchored = true
p.Color = Color3.new(1)
p.formFactor = "Symmetric"
p.Parent = game.Workspace
--wait(.1)
end

Waves

Still working on smoothing out waves
x=1
y=1
z=1

for i = 0, 5, 1 do
for j = 0, 5, 1 do
for k = 0, 5, 1 do

x=i
y=i^2
z=i

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(i,1+y/2,k))
p.Size = Vector3.new(1,y,1)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
--wait(1)

end
end
end

for i = 6, 11, 1 do 
for j = 10, 6, -1 do
for k = 0, 5, 1 do

x=i
y=((i-6)^2)
z=i

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(16-i,1+y/2,k))
p.Size = Vector3.new(1,y,1)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
--wait(1)

end
end
end

Terrain generator

This may be similar to LegoX's Terrain generator. Please compare and contrast to learn and improve your own scripting skills. His uses a pattern of sorts... this relies on a random number generator.

x=1
y=1
z=1

for i = 0, 100, 10 do
for j = 0, 10, 1 do
for k = 0, 100, 10 do

a=math.random(1,20)


x=i
y=a
z=i


p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(i,j,k))
p.Size = Vector3.new(10,a,10)
p.Anchored = true
p.Color = Color3.new(1) -- Please change the color to your own desire.
p.Parent = game.Workspace
--wait(1)

end
end
end

You can fiddle around with that, I've had it make a step pattern, or a smooth slope (it's maybe not the best of ways to make these, perhaps):

x=1
y=1
z=1

for i = 0, 100, 10 do
for k = 0, 100, 10 do
for j = 0, 10, 1 do



x=i
y=math.sqrt(i)
z=k


p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(i,1,k))
p.Size = Vector3.new(10,y,10)
p.Anchored = true
p.Color = Color3.new(1)
p.Parent = game.Workspace
--wait(1)

end
end
end

This isn't terrain but I don't have anyplace else to put them

3D Space

3D space

This requires putting a black decal on the SkyBox in Lighting. Those are freely available in free models. This will make a more realistic space model that you can fly through... fiddle with the numbers to make it bigger.

x=1
y=1
z=1

for i = 1, 100, 1 do -- how many stars

a=math.random(1,100)
b=math.random(1,100)
c=math.random(1,100)

x=a
y=b
z=c


p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(x,y,z)) -- where are the stars
p.Size = Vector3.new(1,1,1) -- small stars
p.Anchored = true
p.CanCollide = false
p.Parent = game.Workspace
p.BrickColor = BrickColor.new(1) -- white stars
end

Fun with floors

Another image that wasn't what I intended it to be, lol


for i = 1, 100, 10 do
for j = 1, 100, 10 do
for k = 1, 100, 10 do

p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(i,j,k))
p.Size = Vector3.new(1,1,1)
p.Anchored = true
p.Color = Color3.new(1)
p.formFactor = "Symmetric"
p.Parent = game.Workspace
--wait(.1)
end
end
end