aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-02-11 21:41:10 +0100
committerorwell96 <orwell@bleipb.de>2019-02-11 21:41:10 +0100
commit4112476bc9c2d29e89bcbe83c5b7073fd38de068 (patch)
tree16ae494a47ceb61e6709c8b1c16256d2b18a5d5a /advtrains_line_automation
parentfcb3dec0c075e86e6a223e2e8df0eb89d06a6466 (diff)
downloadadvtrains-4112476bc9c2d29e89bcbe83c5b7073fd38de068.tar.gz
advtrains-4112476bc9c2d29e89bcbe83c5b7073fd38de068.tar.bz2
advtrains-4112476bc9c2d29e89bcbe83c5b7073fd38de068.zip
Small stoprail fixes
Diffstat (limited to 'advtrains_line_automation')
-rw-r--r--advtrains_line_automation/stoprail.lua39
1 files changed, 25 insertions, 14 deletions
diff --git a/advtrains_line_automation/stoprail.lua b/advtrains_line_automation/stoprail.lua
index cc2c8ac..2610d1c 100644
--- a/advtrains_line_automation/stoprail.lua
+++ b/advtrains_line_automation/stoprail.lua
@@ -137,25 +137,36 @@ local adefunc = function(def, preset, suffix, rotation)
on_train_approach = function(pos,train_id, train, index)
if train.path_cn[index] == 1 then
advtrains.interlocking.lzb_add_oncoming_npr(train, index, 2)
+ local pe = advtrains.encode_pos(pos)
+ local stdata = advtrains.lines.stops[pe]
+ if stdata and stdata.stn then
+ local stn = advtrains.lines.stations[stdata.stn]
+ local stnname = stn and stn.name or "Unknown Station"
+ train.text_inside = "Next Stop:\n"..stnname
+ end
end
end,
on_train_enter = function(pos, train_id)
local train = advtrains.trains[train_id]
-
- local pe = advtrains.encode_pos(pos)
- local stdata = advtrains.lines.stops[pe]
- if not stdata then
- advtrains.atc.train_set_command(train, "B0", true)
- updatemeta(pos)
+ local index = atfloor(train.index)
+ if train.path_cn[index] == 1 then
+ local pe = advtrains.encode_pos(pos)
+ local stdata = advtrains.lines.stops[pe]
+ if not stdata then
+ advtrains.atc.train_set_command(train, "B0", true)
+ updatemeta(pos)
+ end
+
+ local stn = advtrains.lines.stations[stdata.stn]
+ local stnname = stn and stn.name or "Unknown Station"
+
+ -- Send ATC command and set text
+ advtrains.atc.train_set_command(train, "B0 W O"..stdata.doors..(stdata.reverse and "R" or "").." D"..stdata.wait.." OC D1 SM", true)
+ train.text_inside = stnname
+ if tonumber(stdata.wait) then
+ minetest.after(tonumber(stdata.wait), function() train.text_inside = "" end)
+ end
end
-
- local stn = advtrains.lines.stations[stdata.stn]
- local stnname = stn and stn.name or "Unknown Station"
-
- -- Send ATC command and set text
- advtrains.atc.train_set_command(train, "B0 W O"..stdata.doors..(stdata.reverse and "R" or "").." D"..stdata.wait.." OC D1 SM", true)
- train.text_inside = stnname
-
end
},
}