aboutsummaryrefslogtreecommitdiff
path: root/advtrains/helpers.lua
diff options
context:
space:
mode:
authorBlockhead <jbis1337@hotmail.com>2020-09-11 17:18:45 +1000
committerBlockhead <jbis1337@hotmail.com>2020-09-11 17:19:23 +1000
commit487ca4e38cddcb5245b2d42134ee15390b0c1dda (patch)
tree4d9b25686b5ed6417daba1d5e9c60f6ef465dc26 /advtrains/helpers.lua
parent1d224d6b4c714ff63f98d3f935ccbd9f697fb1d9 (diff)
downloadadvtrains-487ca4e38cddcb5245b2d42134ee15390b0c1dda.tar.gz
advtrains-487ca4e38cddcb5245b2d42134ee15390b0c1dda.tar.bz2
advtrains-487ca4e38cddcb5245b2d42134ee15390b0c1dda.zip
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.
Diffstat (limited to 'advtrains/helpers.lua')
-rw-r--r--advtrains/helpers.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua
index 782a5c5..65f25ba 100644
--- a/advtrains/helpers.lua
+++ b/advtrains/helpers.lua
@@ -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