F.crossings={ BeethvV = 3, EldersValley = 4, AckLvcross=2, ML1_unnamed=2, ML1_Scl1=4, freightrwa = 2, smlpatha = 2, spneul = 10, spneul_jnc = 7, MOriStn = 4, MSouthForest1509 = 2, SF1Station = 5, SF1West = 2, SF1SouthWest = 4, Snb=3, LovelaceAve = 5, Onionland = 2, PH_West = 4, PH_WestS = 2, gardonst = 4, Trs_Church = 3, } --[[ Setting up level crossings: 1. choose a name 2. add that into the crossings table, with the number of crossing signs to trigger 3. name the crossing signs 4. for each rail in each direction, add an F.on() and an F.off() rail F.on(, ) F.off(, ) where directionAndRail is another identifier. Always point the arrows in the direction the train is driving. ]]-- if not S.crossst then S.crossst={} end --Point arrows in driving direction! function F.on(cross, inst, inv) if atc_arrow~=inv then local num=F.crossings[cross] if not S.crossst[cross] then S.crossst[cross]={} end S.crossst[cross][inst]=true for i=1,num do setstate(cross..i, "on") end end end function F.off(cross, inst, inv) if atc_arrow~=inv then local num=F.crossings[cross] S.crossst[cross][inst]=nil for _,_ in pairs(S.crossst[cross]) do return end for i=1,num do setstate(cross..i, "off") end end end function F.on_nt(cross, inst, inv) if atc_arrow~=inv then if not S.crossst[cross] then S.crossst[cross]={} end S.crossst[cross][inst]=true local i=1 while is_passive(cross..i) do setstate(cross..i, "on") i=i+1 end end end function F.off_nt(cross, inst, inv) if atc_arrow~=inv then S.crossst[cross][inst]=nil for _,_ in pairs(S.crossst[cross]) do return end local i=1 while is_passive(cross..i) do setstate(cross..i, "off") i=i+1 end end end