local vec3 = require "vec3" local streetutil = require "streetutil" --the two types of roads from which can be chosen local types = {"standard/town_small_new.lua", "standard/town_medium_new.lua", "standard/town_large_new.lua"} local types2 = { "cement.lua","iron.lua","suspension.lua","cable.lua","stone.lua","lu_bridge_invisible.lua"} --the values for the sliders local SegmentL = {30,60, 80, 100, 120, 160,200,240,280,300,320,360,400,440,480,560 } local SegmentStreetL = {30,60, 80, 100, 120, 160,200,240,280,300,320,360,400,440,480,560 } local SegmentStreetR = {30,60, 80, 100, 120, 160,200,240,280,300,320,360,400,440,480,560 } local RoadSpa = { 30, 40, 50, 60, 70, 80, 90,100,110,120} local RoadSpa1 = { 30, 40, 50, 60, 70, 80, 90,100,110,120} local RailSpa = { 10,11, 12,13, 14,15, 16,17, 18,19, 20, 25, 30, 40, 50,60, 70, 80, 90,100} local RailSpa1 = { 10,11, 12,13, 14,15, 16,17, 18,19, 20, 25, 30, 40, 50,60, 70, 80, 90,100} local Numro = { 1,2,3,4,5,6} local Numro1 = { 1,2,3,4,5,6} local Numtr = {1,2,3,4,5,6} local BridgeHeights = { 2,4,6,8,10,12,14,16,18,20 } local DammHeights = { -16,-12,-10,-8,-6,-4,-2,0,2,4,6,8,10,12} local TunnelHeights = { -16} --setting the slider values to string type function data() local segmentLengthValue = {} for i = 1, #SegmentL do segmentLengthValue[i] = _("%s m").format(tostring(SegmentL[i])) end local segmentLength1Value = {} for i = 1, #SegmentStreetL do segmentLength1Value[i] = _("%s m").format(tostring(SegmentStreetL[i])) end local segmentLength2Value = {} for i = 1, #SegmentStreetR do segmentLength2Value[i] = _("%s m").format(tostring(SegmentStreetR[i])) end local StreetSpacingValue = {} for i = 1, #RoadSpa1 do StreetSpacingValue[i] = _("%s m").format(tostring(RoadSpa1[i])) end local RoadSpacingValue = {} for i = 1, #RoadSpa do RoadSpacingValue[i] = _("%s m").format(tostring(RoadSpa[i])) end local RailSpacingValue = {} for i = 1, #RailSpa do RailSpacingValue[i] = _("%s m").format(tostring(RailSpa[i])) end local RailStreetSpacingValue = {} for i = 1, #RailSpa1 do RailStreetSpacingValue[i] = _("%s m").format(tostring(RailSpa1[i])) end local NumberOfRoadsValue = {} for i = 1, #Numro do NumberOfRoadsValue[i] = _("%s m").format(tostring(Numro[i])) end local NumberOfStreetValue = {} for i = 1, #Numro1 do NumberOfStreetValue[i] = _("%s m").format(tostring(Numro1[i])) end local NumberOfTracksValue = {} for i = 1, #Numtr do NumberOfTracksValue[i] = _("%s m").format(tostring(Numtr[i])) end local BridgeHeightsValue = {} for i = 1, #BridgeHeights do BridgeHeightsValue[i] = _("%s m").format(tostring(BridgeHeights[i])) end local DammHeightsValue = {} for i = 1, #DammHeights do DammHeightsValue[i] = _("%s m").format(tostring(DammHeights[i])) end local TunnelHeightsValue = {} for i = 1, #TunnelHeights do TunnelHeightsValue[i] = _("%s m").format(tostring(TunnelHeights[i])) end return { type = "STREET_CONSTRUCTION", description = { name = _("build with bridge"), description = _("bridge construction"), }, availability = {yearFrom = 1925 }, --settings on the settings tab params = { { key = "streetType2", name = _("Number of lanes (med or large road)"), values = { ("Small"), _("Medium"), _("Large") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "Road1Height", name = _("Road right"), values = { ("Ground"), _("Bridge"), _("Damm") , _("Tunnel") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "RoadHeight", name = _("Road left"), values = {("Ground"), _("Bridge"), _("Damm") , _("Tunnel") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "TrackHeight", name = _("Track"), values = { ("Ground"), _("Bridge"), _("Damm") , _("Tunnel")}, defaultIndex =0, yearFrom = 1925, yearTo = 0 }, { key = "BridgeT", name = _("Bridge Type"), values = { ("Cement"), _("Iron"), _("Suspension"), _("Cable"), _("Stone"), _("Invisible") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "BridgeHeight", name = _("Height of bridge"), values = { ("2"),("4"),("6"),("8"), _("10"), _("12"), _("14"), _("16"), _("18"), _("20") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "DammHeight", name = _("Height of Damm"), values = { ("-16"),("-12"), _("-10"), _("-8"), _("-6"), _("-4"), _("-2"),("0"),("2"), _("4"), _("6"), _("8"), _("10"), _("12") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "TunnelHeight", name = _("Height of Tunnel"), values = { ("-16") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "NumberOfRoads", name = _("Number of roads right"), values = { ("1"), _("2"), _("3"), _("4"), _("5"), _("6") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "NumberOfStreet", name = _("Number of roads left"), values = {("1"), _("2"), _("3"), _("4"), _("5"), _("6") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "NumberOfTracks", name = _("Number of tracks"), values = { ("1"), _("2"), _("3"), _("4"), _("5"), _("6") }, defaultIndex = 1, yearFrom = 1925, yearTo = 0 }, { key = "RoadSpacing", name = _("Road to Road center Distance right"), values = { ("30"), _("40"), _("50"), _("60"), _("70"), _("80"), _("90"), _("100"), _("110"), _("120") }, defaultIndex = 3, yearFrom = 1925, yearTo = 0 }, { key = "StreetSpacing", name = _("Road to Road center Distance left"), values = { ("30"), _("40"), _("50"), _("60"), _("70"), _("80"), _("90"), _("100"), _("110"), _("120") }, defaultIndex = 3, yearFrom = 1925, yearTo = 0 }, { key = "RailSpacing", name = _("Road to Rail center Distance right"), values = { ("10"), _("11"), _("12"), _("13"), _("14"), _("15"), _("16"), _("17"), _("18"), _("19") , _("20"), _("25"), _("30"), _("40"), _("50"), _("60"), _("70"), _("80"), _("90"), _("100")}, defaultIndex = 4, yearFrom = 1925, yearTo = 0 }, { key = "RailStreetSpacing", name = _("Road to Rail center Distance left"), values = { ("10"), _("11"), _("12"), _("13"), _("14"), _("15"), _("16"), _("17"), _("18"), _("19") , _("20"), _("25"), _("30"), _("40"), _("50"), _("60"), _("70"), _("80"), _("90"), _("100")}, defaultIndex = 4, yearFrom = 1925, yearTo = 0 }, { key = "segmentLength", name = _("Segment Length Rail"), values = { ("30"), _("60"), _("80"), _("100"), _("120"), _("160"), _("200"), _("240"), _("280"), _("300"), _("320"), _("360"), _("400"), _("440"), _("480"), _("560") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "segmentLength1", name = _("Segment Length right Street"), values = { ("30"), _("60"), _("80"), _("100"), _("120"), _("160"), _("200"), _("240"), _("280"), _("300"), _("320"), _("360"), _("400"), _("440"), _("480"), _("560") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, { key = "segmentLength2", name = _("Segment Length left Street"), values = { ("30"), _("60"), _("80"), _("100"), _("120"), _("160"), _("200"), _("240"), _("280"), _("300"), _("320"), _("360"), _("400"), _("440"), _("480"), _("560") }, defaultIndex = 0, yearFrom = 1925, yearTo = 0 }, }, updateFn = function(params) local result = { } result.models = { } local streetDist = 1 local halfWidth = params.streetType2 == 1 and 18 or 11 local center = RoadSpa[params.RoadSpacing + 1] local center1 = RoadSpa1[params.StreetSpacing + 1] local segmentLength = SegmentL[params.segmentLength+1] local segmentLength1 = SegmentStreetL[params.segmentLength1+1] local segmentLength2 = SegmentStreetR[params.segmentLength2+1] local centerRail = RailSpa[params.RailSpacing + 1] local centerRail1 = RailSpa1[params.RailStreetSpacing + 1] local RoadHeight = params.RoadHeight local Road1Height = params.Road1Height local TrackHeight = params.TrackHeight local NumRoads = Numro[params.NumberOfRoads + 1] local NumRoads1 = Numro1[params.NumberOfStreet + 1] local NumTracks = Numtr[params.NumberOfTracks + 1] local NumTracksfa = (NumTracks*2)-1 local BridgeHeight = BridgeHeights[params.BridgeHeight+1] local DammHeight = DammHeights[params.DammHeight+1] local TunnelHeight = TunnelHeights[params.TunnelHeight+1] local InclBridge = params.Bridge local SnapNodesArray={} for i= 0,NumTracksfa do SnapNodesArray[i+1]=i end local x = { segmentLength, -segmentLength, segmentLength+10, -segmentLength-10,segmentLength1, -segmentLength1, segmentLength1+10, -segmentLength1-10,segmentLength2, -segmentLength2, segmentLength2+10, -segmentLength2-10} local y = { 0 , center,center1, -centerRail, -centerRail-10 ,-centerRail1, -centerRail1-10 } local z = {0, BridgeHeight, DammHeight, -16} local Redges = { } local yrloop = centerRail for i = 1,NumRoads do local RoadHeight = params.RoadHeight or 0 if RoadHeight == 0 then streetutil.addStraightEdge(Redges, vec3.new( 0.5*segmentLength1, 0+yrloop, z[1]), vec3.new( 0.5*-segmentLength1, 0+yrloop, z[1])) elseif RoadHeight == 1 then streetutil.addStraightEdge(Redges, vec3.new( 0.5*segmentLength1, 0+yrloop, z[2]), vec3.new( 0.5*-segmentLength1, 0+yrloop, z[2])) elseif RoadHeight == 2 then streetutil.addStraightEdge(Redges, vec3.new( 0.5*segmentLength1, 0+yrloop, z[3]), vec3.new( 0.5*-segmentLength1, 0+yrloop, z[3])) elseif RoadHeight == 3 then streetutil.addStraightEdge(Redges, vec3.new( 0.5*segmentLength1, 0+yrloop, z[4]), vec3.new( 0.5*-segmentLength1, 0+yrloop, z[4])) end yrloop = yrloop+center end local medges = { } local yrloop = centerRail1 for i = 1,NumRoads1 do local Road1Height = params.Road1Height or 0 if Road1Height == 0 then streetutil.addStraightEdge(medges, vec3.new( 0.5*segmentLength2, 0-yrloop, z[1]), vec3.new( 0.5*-segmentLength2, 0-yrloop, z[1])) elseif Road1Height == 1 then streetutil.addStraightEdge(medges, vec3.new( 0.5*segmentLength2, 0-yrloop, z[2]), vec3.new( 0.5*-segmentLength2, 0-yrloop, z[2])) elseif Road1Height == 2 then streetutil.addStraightEdge(medges, vec3.new( 0.5*segmentLength2, 0-yrloop, z[3]), vec3.new( 0.5*-segmentLength2, 0-yrloop, z[3])) elseif Road1Height == 3 then streetutil.addStraightEdge(medges, vec3.new( 0.5*segmentLength2, 0-yrloop, z[4]), vec3.new( 0.5*-segmentLength2, 0-yrloop, z[4])) end yrloop = yrloop+center1 end local ledges = { } local ytloop = -2.5 local ytoffset = -5 for i = 1,NumTracks do local TrackHeight = params.TrackHeight or 0 if TrackHeight == 0 then streetutil.addStraightEdge(ledges, vec3.new( 0.5*segmentLength, 0+ytloop, z[1]), vec3.new( 0.5*-segmentLength, 0+ytloop, z[1])) elseif TrackHeight == 1 then streetutil.addStraightEdge(ledges, vec3.new( 0.5*segmentLength, 0+ytloop, z[2]), vec3.new( 0.5*-segmentLength, 0+ytloop, z[2])) elseif TrackHeight == 2 then streetutil.addStraightEdge(ledges, vec3.new( 0.5*segmentLength, 0+ytloop, z[3]), vec3.new( 0.5*-segmentLength, 0+ytloop, z[3])) elseif TrackHeight == 3 then streetutil.addStraightEdge(ledges, vec3.new( 0.5*segmentLength, 0+ytloop, z[4]), vec3.new( 0.5*-segmentLength, 0+ytloop, z[4])) end ytloop = ytloop - ytoffset * i ytoffset = ytoffset * -1 end local roadEdge = { } local trackEdge = { } local road1Edge = { } if RoadHeight == 1 then roadEdge = { type = "STREET", params = { type = types[params.streetType2 + 1], }, edgeType = "BRIDGE", edgeTypeName = types2[params.BridgeT+1], edges = Redges, snapNodes = {0,1}, freeNodes = streetutil.freeAllNodes(Redges), } elseif RoadHeight == 0 then roadEdge = { type = "STREET", params = { type = types[params.streetType2 + 1], }, edges = Redges, snapNodes = {0,1}, freeNodes = streetutil.freeAllNodes(Redges), } elseif RoadHeight == 2 then roadEdge = { type = "STREET", params = { type = types[params.streetType2 + 1], }, edges = Redges, snapNodes = {0,1}, freeNodes = streetutil.freeAllNodes(Redges), } elseif RoadHeight == 3 then roadEdge = { type = "STREET", params = { type = types[params.streetType2 + 1], }, edgeType = "TUNNEL", -- optional edgeTypeName = "street_old.lua", -- optional edges = Redges, snapNodes = {0,1}, freeNodes = streetutil.freeAllNodes(Redges), } end if Road1Height == 1 then road1Edge = { type = "STREET", params = { type = types[params.streetType2 + 1], }, edgeType = "BRIDGE", edgeTypeName = types2[params.BridgeT+1], edges = medges, snapNodes = {0,1}, freeNodes = streetutil.freeAllNodes(medges), } elseif Road1Height == 0 then road1Edge = { type = "STREET", params = { type = types[params.streetType2 + 1], }, edges = medges, snapNodes = {0,1}, freeNodes = streetutil.freeAllNodes(medges), } elseif Road1Height == 2 then road1Edge = { type = "STREET", params = { type = types[params.streetType2 + 1], }, edges = medges, snapNodes = {0,1}, freeNodes = streetutil.freeAllNodes(medges), } elseif Road1Height == 3 then road1Edge = { type = "STREET", params = { type = types[params.streetType2 + 1], }, edgeType = "TUNNEL", -- optional edgeTypeName = "street_old.lua", -- optional edges = medges, snapNodes = {0,1}, freeNodes = streetutil.freeAllNodes(medges), } end if TrackHeight == 1 then trackEdge = { type = "TRACK", params = { type = "standard_speed.lua", catenary = true }, edgeType = "BRIDGE", edgeTypeName = types2[params.BridgeT+1], edges = ledges, snapNodes = SnapNodesArray } elseif TrackHeight == 0 then trackEdge = { type = "TRACK", params = { type = "standard.lua", catenary = true }, edges = ledges, snapNodes = SnapNodesArray } elseif TrackHeight == 2 then trackEdge = { type = "TRACK", params = { type = "standard.lua", catenary = true }, edges = ledges, snapNodes = SnapNodesArray } elseif TrackHeight == 3 then trackEdge = { type = "TRACK", params = { type = "standard.lua", catenary = true }, edgeType = "TUNNEL", -- optional edgeTypeName = "railroad_old.lua", -- optional edges = ledges, snapNodes = SnapNodesArray } end result.edgeLists = {roadEdge, trackEdge,road1Edge} result.groundFaces = { } result.cost = 0 return result end } end