Enable three-way turnouts with proper conns support on all sides
I chose to make three-way turnouts have 5 conns (last one is not used) so that they can be distinguished from crossings easily without refactoring the code. Three-ways should have their last entry with {["3"]=0} instead as a sort of internal mark.
This commit is contained in:
parent
1d224d6b4c
commit
487ca4e38c
|
@ -334,9 +334,10 @@ function advtrains.get_adjacent_rail(this_posnr, this_conns_p, conn_idx, drives_
|
|||
end
|
||||
|
||||
-- when a train enters a rail on connid 'conn', which connid will it go out?
|
||||
-- nconns: number of connections in connection table
|
||||
-- nconns: number of connections in connection table:
|
||||
-- 2 = straight rail; 3 = turnout, 4 = crossing, 5 = three-way turnout (5th entry is a stub)
|
||||
-- returns: connid_out
|
||||
local connlku={[2]={2,1}, [3]={2,1,1}, [4]={2,1,4,3}}
|
||||
local connlku={[2]={2,1}, [3]={2,1,1}, [4]={2,1,4,3}, [5]={2,1,1,1}}
|
||||
function advtrains.get_matching_conn(conn, nconns)
|
||||
return connlku[nconns][conn]
|
||||
end
|
||||
|
|
|
@ -124,8 +124,7 @@ advtrains.ap.t_s3way={
|
|||
regstep=1,
|
||||
variant={
|
||||
l={
|
||||
--conns = conns6(0,7,0,8,0,9),
|
||||
conns = conns3(0,7,8),
|
||||
conns = { {c=0}, {c=7}, {c=8}, {c=9}, {["3"]=0} },
|
||||
desc = "3-way turnout (left)",
|
||||
switchalt = "s",
|
||||
--switchalt2 = ,
|
||||
|
@ -133,16 +132,14 @@ advtrains.ap.t_s3way={
|
|||
switchst="l",
|
||||
},
|
||||
s={
|
||||
--conns = conns6(0,8,0,7,0,9),
|
||||
conns = conns3(0,8,7),
|
||||
conns = { {c=0}, {c=8}, {c=7}, {c=9}, {["3"]=0} },
|
||||
desc = "3-way turnout (straight)",
|
||||
switchalt ="r",
|
||||
--switchmc = "on",
|
||||
switchst = "s",
|
||||
},
|
||||
r={
|
||||
--conns = conns6(0,9,0,8,0,7),
|
||||
conns = conns3(0,9,8),
|
||||
conns = { {c=0}, {c=9}, {c=8}, {c=7}, {["3"]=0} },
|
||||
desc = "3-way turnout (right)",
|
||||
switchalt = "l",
|
||||
switchst="r"
|
||||
|
|
Loading…
Reference in New Issue