Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- streaming = false
- CityName = "Framingham"
- CityState = nil
- TerrainSize = 25
- CitySize = 10;
- Climate = 39 --1 to 100 cold hot
- Brightness = 2
- Flat = false
- WaterLevel = 10
- ElevationChange = math.random(1,3)
- Interstate = true
- MaxY = 40 + WaterLevel
- GroundColor = "Medium green"
- GroundMaterial = "Grass"
- TreeColor = "Camo"
- function SetUpClimate()
- local AllClimates = {
- "Snowy",
- "Temperate",
- "Tropical",
- "Desert",
- "Plains",
- }
- local SelectedClimate = math.random(1,#AllClimates)
- SelectedClimate = AllClimates[SelectedClimate]
- print("Generating a ".. SelectedClimate.. " climate");
- if SelectedClimate == "Snowy" then
- GroundColor = "White"
- GroundMaterial = "Sand"
- game.Lighting.FogColor = Vector3.new(255,255,255)
- game.Lighting.FogEnd = 1000;
- end
- if SelectedClimate == "Snowy" then
- GroundColor = "White"
- GroundMaterial = "Sand"
- end
- end
- function SetUpGameCorrectly()
- -- script.Imports.Vehicles.Parent = game.Lighting;
- script.Sky.Parent = game.Lighting;
- script.ServerEvents.Parent = game.ServerScriptService;
- script.Events.Chop.Parent = game.ReplicatedStorage;
- script.InventoryGiver.Parent = game.ServerScriptService;
- game.Lighting.Brightness = Brightness
- game.Lighting.FogStart = 100
- print("Make sure FE is Enabled")
- game.Workspace.Gravity = 196.2;
- if streaming == true then
- game.Workspace.StreamingEnabled = true;
- else
- game.Workspace.StreamingEnabled = false;
- end
- if game.Workspace.Baseplate then
- game.Workspace.Baseplate:Destroy()
- end
- end
- function MakeFolders(name)
- local newFolder = Instance.new("Folder");
- newFolder.Parent = workspace;
- newFolder.Name = name;
- end
- SetUpGameCorrectly()
- MakeFolders("Trees");
- MakeFolders("TerrainG");
- MakeFolders("Roads");
- MakeFolders("Props");
- MaxFog = 0; --Init
- row = 0; --Init
- countUp = 0; -- init
- previous = 4 -- init
- CountUpArray = {}; -- init
- TreesC = math.random(1,5)
- TreeCounter = 0; -- Init
- RandomStage = 0; --Init
- InterstateRow = nil; -- init
- if Interstate == true then
- InterstateRow = math.random(3,TerrainSize-4)
- if InterstateRow % 2 == 0 then
- InterstateRow = InterstateRow + 0
- else
- InterstateRow = InterstateRow + 1
- end
- print("Row "..InterstateRow.. " was selected for the interstate!")
- end
- function GenerateTerrain()
- while row < TerrainSize do
- while countUp < TerrainSize do
- wait(0.01)
- local TerrainPeice = Instance.new("Part");
- TerrainPeice.Anchored = true;
- TerrainPeice.Transparency = 0;
- TerrainPeice.CanCollide = true;
- TerrainPeice.Size = Vector3.new(64,40,64)
- TerrainPeice.Name = "Ground"
- if previous <= WaterLevel and not math.random(1,100) == 1 then
- previous = WaterLevel
- else
- previous = previous + math.random(-4*ElevationChange,4*ElevationChange)
- if previous > MaxY then
- previous = MaxY
- end
- end
- previous = math.floor(previous)
- if CountUpArray[countUp] then
- if CountUpArray[countUp]+4> previous then
- if CountUpArray[countUp] <= WaterLevel and not math.random(1,100)== 1 then
- previous = WaterLevel
- else
- previous = (previous + CountUpArray[countUp])/2
- end
- end
- if CountUpArray[countUp]-4 < previous then
- if CountUpArray[countUp] <= WaterLevel and not math.random(1,100) == 1 then
- previous = WaterLevel
- else
- previous = (CountUpArray[countUp] + previous)/2
- end
- end
- if row + 5 >= InterstateRow and row-5 <= InterstateRow then
- if CountUpArray[countUp] > WaterLevel + 2 then
- previous = previous - (previous/5)
- end
- if previous <= WaterLevel then
- previous = WaterLevel + 1
- end
- end
- end
- if Flat == true then
- TerrainPeice.Position = Vector3.new(64*countUp,4,64*row)
- else
- if row == InterstateRow or row == InterstateRow + 1 then
- TerrainPeice.Name = "InterstateGround"
- TerrainPeice.Position = Vector3.new(64*countUp,WaterLevel + 1,64*row)
- else
- TerrainPeice.Position = Vector3.new(64*countUp,previous,64*row)
- end
- end
- if true then
- TerrainPeice.Material = GroundMaterial
- TerrainPeice.BrickColor = BrickColor.new(GroundColor)
- TerrainPeice.Name = "Grass"
- if row == InterstateRow or row == InterstateRow + 1 then
- TerrainPeice.Name = "InterstateGround";
- previous = WaterLevel + 1;
- TerrainPeice.Position = Vector3.new(64*countUp,WaterLevel + 1,64*row)
- if row == InterstateRow then
- local Road = script.Imports.Road.InterstateSegment:Clone()
- Road:SetPrimaryPartCFrame(TerrainPeice.CFrame * CFrame.Angles(0, math.rad(90), 0)*CFrame.new(-32,20,0))
- Road.Parent = game.Workspace.Roads;
- end
- end
- MaxFog = 1400;
- if previous <= WaterLevel then
- TerrainPeice.Material = "Foil"
- TerrainPeice.BrickColor = BrickColor.new("Cyan")
- TerrainPeice.CanCollide = false;
- TerrainPeice.Position = Vector3.new(TerrainPeice.Position.X,WaterLevel,TerrainPeice.Position.Z)
- else
- if TerrainPeice.Position.Y > WaterLevel + 2 then
- local newTree = script.Imports.Tree.OakTree:Clone()
- local randomX = math.random(-30,30)
- local randomZ = math.random(-30,30)
- local randomX1 = math.random(-30,30)
- local randomZ1 = math.random(-30,30)
- --print(randomX);
- if RandomStage == 0 then
- newTree:SetPrimaryPartCFrame((TerrainPeice.CFrame)*CFrame.new(randomX,5+math.random(1,10),randomZ))
- RandomStage = RandomStage + 1
- end
- if RandomStage == 1 then
- newTree:SetPrimaryPartCFrame((TerrainPeice.CFrame)*CFrame.new(randomX1,5+math.random(1,10),randomZ1))
- RandomStage = 0
- end
- newTree.Parent = game.Workspace.Trees
- end
- end
- end
- if TerrainPeice.Name == "InterstateGround" then
- TerrainPeice.Material = "Pebble";
- TerrainPeice.BrickColor = BrickColor.new("Fossil");
- end
- previous = TerrainPeice.Position.Y;
- TerrainPeice.Parent = game.Workspace:WaitForChild("TerrainG");
- CountUpArray[countUp] = TerrainPeice.Position.Y;
- countUp = countUp + 1;
- end
- print("Building terrain.. "..math.floor((row/TerrainSize)*100).."%");
- row = row + 1;
- countUp = 0;
- end
- end
- GenerateTerrain();
- Sel = Instance.new("Part")
- Sel.Name = "Selection";
- Sel.Size = Vector3.new(64,720,64);
- Sel.BrickColor = BrickColor.new("Really red")
- Sel.Material = "Plastic";
- Sel.Parent = game.Workspace
- Sel.Position = Vector3.new(0,WaterLevel,InterstateRow*64)
- Sel.Anchored = true
- Sel.CanCollide = true;
- --:GetTouchingParts()
- mathstore1 = 0
- mathstore2 = 0
- mathstore3 = 0
- function InteractSel(action)
- --[[ ACTIONS
- /PlaceRoadRot0
- /PlaceRoadRot90
- /RadioTower
- /PlaceInt4WNT
- /MainRoadX
- ]]
- local count = 1
- if action == "PlaceRoadRot0" then
- --
- local newRoad = script.Imports.Road.RoadSegment:Clone();
- newRoad.Parent = game.Workspace.Roads;
- Sel.Orientation = Vector3.new(0,0,0);
- local SelCfr = Sel.CFrame
- print(SelCfr)
- newRoad:SetPrimaryPartCFrame(SelCfr*CFrame.new(0,21,0))
- --
- local TouchingParts = game.Workspace.Selection:GetTouchingParts();
- local NumT = #TouchingParts
- print(NumT)
- while count < NumT+1 do
- print("CountUp")
- if TouchingParts[count].Name == "Grass" then
- local PartSelected = TouchingParts[count]
- local PartSP = PartSelected.Position
- PartSelected.Position = Vector3.new(PartSP.X,WaterLevel+1,PartSP.Z)
- PartSelected.Name = "UsedLand"
- end
- if TouchingParts[count].Name == "TrunkDetector" then
- local SelectedTree = TouchingParts[count]
- SelectedTree.Parent.Parent:Destroy();
- end
- count = count + 1;
- end
- count = 1
- end
- ----------------------------------------------------------------------------------------
- if action == "MainRoadX" then
- --
- Sel.Position = Vector3.new(Sel.Position.X+32,Sel.Position.Y,Sel.Position.Z+32)
- Sel.Size = Vector3.new(Sel.Size.X+64,Sel.Size.Y,Sel.Size.Z+64)
- local newRoad = script.Imports.Road.MajorRoad1:Clone();
- newRoad.Parent = game.Workspace.Roads;
- Sel.Orientation = Vector3.new(0,0,0);
- local SelCfr = Sel.CFrame
- newRoad:SetPrimaryPartCFrame(SelCfr*CFrame.new(0,21,0))
- --
- local TouchingParts = game.Workspace.Selection:GetTouchingParts();
- local NumT = #TouchingParts
- while count < NumT+1 do
- if TouchingParts[count].Name == "Grass" then
- local PartSelected = TouchingParts[count]
- local PartSP = PartSelected.Position
- local Level = Sel.Position.Y;
- PartSelected.Position = Vector3.new(PartSP.X,WaterLevel+1,PartSP.Z)
- PartSelected.Name = "UsedLand"
- end
- if TouchingParts[count].Name == "TrunkDetector" then
- local SelectedTree = TouchingParts[count]
- SelectedTree.Parent.Parent:Destroy();
- end
- if TouchingParts[count].Name == "Road" then
- TouchingParts[count].Parent:Destroy();
- newRoad:Destroy();
- local Intersection = script.Imports.Road.InterstateMain4TL:Clone()
- Intersection.Parent = game.Workspace.Roads;
- Intersection:SetPrimaryPartCFrame(SelCfr * CFrame.new(0,21,0));
- end
- count = count + 1;
- end
- count = 1
- Sel.Size = Vector3.new(Sel.Size.X-64,Sel.Size.Y,Sel.Size.Z-64)
- Sel.Position = Vector3.new(Sel.Position.X-32,Sel.Position.Y,Sel.Position.Z-32)
- end
- ----------------------------------------------------------------------------------------
- count = 1
- if action == "PlaceRoadRot90" then
- --
- local newRoad = script.Imports.Road.RoadSegment:Clone();
- newRoad.Parent = game.Workspace.Roads;
- Sel.Orientation = Vector3.new(0,90,0);
- local SelCfr = Sel.CFrame
- newRoad:SetPrimaryPartCFrame(SelCfr*CFrame.new(0,21,0))
- --
- local TouchingParts = game.Workspace.Selection:GetTouchingParts();
- local NumT = #TouchingParts
- while count < NumT+1 do
- if TouchingParts[count].Name == "Grass" then
- local PartSelected = TouchingParts[count]
- local PartSP = PartSelected.Position
- PartSelected.Position = Vector3.new(PartSP.X,WaterLevel+1,PartSP.Z)
- PartSelected.Name = "UsedLand"
- end
- if TouchingParts[count].Name == "TrunkDetector" then
- local SelectedTree = TouchingParts[count]
- SelectedTree.Parent.Parent:Destroy();
- end
- count = count + 1;
- end
- count = 1
- end
- if action == "PlaceInt4WNT" then
- --
- local newRoad = script.Imports.Road.FourINTNP:Clone();
- newRoad.Parent = game.Workspace.Roads;
- Sel.Orientation = Vector3.new(0,90,0);
- local SelCfr = Sel.CFrame
- newRoad:SetPrimaryPartCFrame(SelCfr*CFrame.new(0,21,0))
- --
- local TouchingParts = game.Workspace.Selection:GetTouchingParts();
- local NumT = #TouchingParts
- while count < NumT+1 do
- if TouchingParts[count].Name == "Grass" then
- local PartSelected = TouchingParts[count]
- local PartSP = PartSelected.Position
- PartSelected.Position = Vector3.new(PartSP.X,WaterLevel+1,PartSP.Z)
- PartSelected.Name = "UsedLand"
- end
- if TouchingParts[count].Name == "TrunkDetector" then
- local SelectedTree = TouchingParts[count]
- SelectedTree.Parent.Parent:Destroy();
- end
- count = count + 1;
- end
- count = 1
- end
- if action == "MoveZ+" then
- Sel.Position = Vector3.new(Sel.Position.X,Sel.Position.Y,Sel.Position.Z+64);
- wait(0.1)
- end
- if action == "MoveZ-" then
- Sel.Position = Vector3.new(Sel.Position.X,Sel.Position.Y,Sel.Position.Z-64);
- wait(0.1)
- end
- if action == "MoveX+" then
- Sel.Position = Vector3.new(Sel.Position.X+64,Sel.Position.Y,Sel.Position.Z);
- wait(0.1)
- end
- if action == "MoveX-" then
- Sel.Position = Vector3.new(Sel.Position.X-64,Sel.Position.Y,Sel.Position.Z);
- wait(0.1)
- end
- if action == "RadioTower" then
- print(Sel.Position)
- print("Spawning RadioTower")
- local TouchingThings = Sel:GetTouchingParts()
- local TouchingCount = #TouchingThings
- while TouchingCount > 0 do
- TouchingThings[TouchingCount].Material = "Concrete";
- TouchingThings[TouchingCount].BrickColor = BrickColor.new("Ghost grey");
- local selType = math.random(1,3)
- wait(1)
- if selType == 1 then
- local tower = script.Imports.Props.RadioTower1:Clone()
- tower.Parent = game.Workspace.Props
- tower:SetPrimaryPartCFrame(Sel.CFrame)
- end
- if selType == 2 then
- print("2 T")
- local tower = script.Imports.Props.RadioTower2:Clone()
- tower.Parent = game.Workspace.Props
- tower:SetPrimaryPartCFrame(Sel.CFrame)
- end
- if selType == 3 then
- print("3 T")
- local tower = script.Imports.Props.RadioTower3:Clone()
- tower.Parent = game.Workspace.Props
- tower:SetPrimaryPartCFrame(Sel.CFrame)
- end
- TouchingCount = TouchingCount - 1
- end
- end
- end
- function GenerateRoadGrid(LengthZ,HeightX,Corner1,Corner2,Corner3,Corner4)
- local counter = LengthZ
- while counter > 0 do
- InteractSel("MoveZ-")
- InteractSel("PlaceRoadRot0");
- counter = counter - 1
- end
- InteractSel("MoveZ-")
- if Corner1 == "4NT" then
- InteractSel("PlaceInt4WNT")
- end
- counter = HeightX
- while counter > 0 do
- InteractSel("MoveX-")
- InteractSel("PlaceRoadRot90")
- counter = counter - 1;
- end
- InteractSel("MoveX-")
- if Corner1 == "4NT" then
- InteractSel("PlaceInt4WNT")
- end
- counter = LengthZ
- while counter > 0 do
- InteractSel("MoveZ+")
- InteractSel("PlaceRoadRot0");
- counter = counter - 1
- end
- InteractSel("MoveZ+")
- if Corner1 == "4NT" then
- InteractSel("PlaceInt4WNT")
- end
- counter = HeightX
- while counter > 0 do
- InteractSel("MoveX+")
- InteractSel("PlaceRoadRot90")
- counter = counter - 1;
- end
- InteractSel("MoveX+")
- if Corner1 == "4NT" then
- InteractSel("PlaceInt4WNT")
- end
- end
- function GenerateRoads()
- local MainRoads = math.random(1,(math.floor(TerrainSize/10)))
- local count = 0
- while MainRoads > 0 do
- Sel.Position = Vector3.new(64*math.random(1,(TerrainSize - 2)),Sel.Position.Y,0)
- if math.random(1,2) == 1 then
- print("Spawning Road X")
- while count < TerrainSize/2 do
- InteractSel("MainRoadX")
- InteractSel("MoveZ+")
- InteractSel("MoveZ+")
- count = count + 1
- end
- Sel.Position = Vector3.new(Sel.Position.X,WaterLevel,Sel.Position.Z)
- count = 0
- wait(1)
- else
- print("Spawning Road X")
- while count < TerrainSize/2 do
- InteractSel("MainRoadX")
- InteractSel("MoveZ+")
- InteractSel("MoveZ+")
- count = count + 1
- end
- count = 0
- wait(1)
- end
- MainRoads = MainRoads - 1
- wait(1);
- end
- InteractSel("MoveX+");
- InteractSel("MoveX+");
- InteractSel("MoveX+");
- InteractSel("MoveX+");
- InteractSel("MoveZ+");
- InteractSel("MoveZ+");
- InteractSel("MoveZ+");
- GenerateRoadGrid(5,3,"4NT","4NT","4NT","4NT")
- end
- mathstore2 = 0
- FindX = math.random(1,TerrainSize)
- FindZ = math.random(1,TerrainSize)
- function GenerateCity()
- GenerateRoads()
- local NumRadioTowers = math.random(1,math.floor(TerrainSize/10))
- while NumRadioTowers > 0 do
- NumRadioTowers = NumRadioTowers - 1
- while FindX == mathstore1 do
- FindX = math.random(1,TerrainSize-1)
- end
- while FindZ == mathstore2 do
- FindZ = math.random(1,TerrainSize-1)
- end
- mathstore1 = FindX
- mathstore2 = FindZ
- Sel.Position = Vector3.new(FindX*64,WaterLevel+1,FindZ*64);
- InteractSel("RadioTower");
- end
- end
- GenerateCity()
- game.Workspace.Selection:Destroy();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement