diff options
author | Blockhead <jbis1337@hotmail.com> | 2020-09-11 02:40:02 +1000 |
---|---|---|
committer | Blockhead <jbis1337@hotmail.com> | 2020-09-11 04:25:38 +1000 |
commit | 1d224d6b4c714ff63f98d3f935ccbd9f697fb1d9 (patch) | |
tree | 5fe70e52cc6d22240451d4a012219888015787f7 /advtrains/tracks.lua | |
parent | 7879a0a215547b0e40f5c1469b72547e7633aca7 (diff) | |
download | advtrains-1d224d6b4c714ff63f98d3f935ccbd9f697fb1d9.tar.gz advtrains-1d224d6b4c714ff63f98d3f935ccbd9f697fb1d9.tar.bz2 advtrains-1d224d6b4c714ff63f98d3f935ccbd9f697fb1d9.zip |
Add 3-way turnouts and y-turnouts (both diverging)
Diffstat (limited to 'advtrains/tracks.lua')
-rw-r--r-- | advtrains/tracks.lua | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua index 8597dac..a9118fc 100644 --- a/advtrains/tracks.lua +++ b/advtrains/tracks.lua @@ -98,6 +98,61 @@ advtrains.ap.t_30deg_flat={ },
rotation={"", "_30", "_45", "_60"},
}
+advtrains.ap.t_yturnout={
+ regstep=1,
+ variant={
+ l={
+ conns = conns3(0,7,9),
+ desc = "Y-turnout (left)",
+ switchalt = "r",
+ switchmc = "off",
+ switchst = "l",
+ },
+ r={
+ conns = conns3(0,9,7),
+ desc = "Y-turnout (right)",
+ switchalt = "l",
+ switchmc = "on",
+ switchst = "r",
+ }
+ },
+ regtp=true,
+ tpdefault="l",
+ rotation={"", "_30", "_45", "_60"},
+}
+advtrains.ap.t_s3way={
+ regstep=1,
+ variant={
+ l={
+ --conns = conns6(0,7,0,8,0,9),
+ conns = conns3(0,7,8),
+ desc = "3-way turnout (left)",
+ switchalt = "s",
+ --switchalt2 = ,
+ --switchmc = "off",
+ switchst="l",
+ },
+ s={
+ --conns = conns6(0,8,0,7,0,9),
+ conns = conns3(0,8,7),
+ 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),
+ desc = "3-way turnout (right)",
+ switchalt = "l",
+ switchst="r"
+ --switchmc = "off",
+ }
+ },
+ regtp=true,
+ tpdefault="l",
+ rotation={"", "_30", "_45", "_60"},
+}
advtrains.ap.t_30deg_slope={
regstep=1,
variant={
@@ -450,10 +505,11 @@ function advtrains.register_tracks(tracktype, def, preset) if var.switchalt and var.switchst then
local switchfunc=function(pos, node, newstate)
+ newstate = newstate or var.switchalt -- support for 3 (or more) state switches
-- this code is only called from the internal setstate function, which
-- ensures that it is safe to switch the turnout
if newstate~=var.switchst then
- advtrains.ndb.swap_node(pos, {name=def.nodename_prefix.."_"..var.switchalt..rotation, param2=node.param2})
+ advtrains.ndb.swap_node(pos, {name=def.nodename_prefix.."_"..newstate..rotation, param2=node.param2})
advtrains.invalidate_all_paths(pos)
end
end
|