aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
authorywang <yw05@forksworld.de>2021-11-03 18:55:31 +0100
committerywang <yw05@forksworld.de>2021-11-07 13:49:01 +0100
commitbe2f37a0678c66278d1c491b8f1250a8a3be9feb (patch)
treeff592e9890892b0d0c6c9dc9b5e8ec81f76a956c /advtrains_interlocking
parent22994705235dfcdfbdc9966a9ba037d657188b5a (diff)
downloadadvtrains-be2f37a0678c66278d1c491b8f1250a8a3be9feb.tar.gz
advtrains-be2f37a0678c66278d1c491b8f1250a8a3be9feb.tar.bz2
advtrains-be2f37a0678c66278d1c491b8f1250a8a3be9feb.zip
Support different types of speed restrictions; add documentation
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/approach.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/advtrains_interlocking/approach.lua b/advtrains_interlocking/approach.lua
index f60468a..eecf09a 100644
--- a/advtrains_interlocking/approach.lua
+++ b/advtrains_interlocking/approach.lua
@@ -14,19 +14,19 @@ local SHUNT_SPEED_MAX = advtrains.SHUNT_SPEED_MAX
local il = advtrains.interlocking
-local function get_over_function(speed, shunt)
+local function get_over_function(speed, shunt, asptype)
return function(pos, id, train, index, speed, lzbdata)
if speed == 0 and minetest.settings:get_bool("at_il_force_lzb_halt") then
atwarn(id,"overrun LZB 0 restriction (red signal) ",pos)
-- Set train 1 index backward. Hope this does not lead to bugs...
--train.index = index - 0.5
- train.speed_restriction = 0
+ advtrains.speed.set_restriction(train, "main", 0)
--TODO temporary
--advtrains.drb_dump(id)
--error("Debug: "..id.." triggered LZB-0")
else
- train.speed_restriction = speed
+ advtrains.speed.set_restriction(train, asptype, speed or -1)
train.is_shunt = shunt
end
--atdebug("train drove over IP: speed=",speed,"shunt=",shunt)
@@ -94,6 +94,7 @@ advtrains.tnc_register_on_approach(function(pos, id, train, index, has_entered,
end
-- nspd can now be: 1. !=0: new speed restriction, 2. =0: stop here or 3. nil: keep travspd
if nspd then
+ travspd = nspd
if nspd == -1 then
travspd = nil
else
@@ -106,7 +107,7 @@ advtrains.tnc_register_on_approach(function(pos, id, train, index, has_entered,
lspd = travspd
local udata = {signal_pos = spos}
- local callback = get_over_function(lspd, travsht)
+ local callback = get_over_function(lspd, travsht, asp.type)
lzbdata.il_shunt = travsht
lzbdata.il_speed = travspd
--atdebug("new lzbdata",lzbdata)