From 267ce6fe6da5c8a59c6ccdbb86b0c66d4398e098 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 17 Oct 2018 19:10:37 +0200 Subject: Prevent any user control except "Brake" when an ATC override is present Solves the problem of accidentally breaking atc-driven trains --- advtrains/trainhud.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'advtrains/trainhud.lua') diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua index 6332c47..0175410 100644 --- a/advtrains/trainhud.lua +++ b/advtrains/trainhud.lua @@ -26,7 +26,7 @@ function advtrains.on_control_change(pc, train, flip) if pc.right then train.tarvelocity = 8 end - if pc.jump then + --[[if pc.jump then train.brake = true --0: released, 1: brake and pressed, 2: released and brake, 3: pressed and brake if not train.brake_hold_state or train.brake_hold_state==0 then @@ -39,18 +39,22 @@ function advtrains.on_control_change(pc, train, flip) elseif train.brake_hold_state==3 then train.brake = false train.brake_hold_state = 0 - end + end]] --shift+use:see wagons.lua else local act=false - if pc.up then - train.ctrl.user=4 - act=true - end if pc.jump then train.ctrl.user = 1 act=true end + -- If atc command set, only "Jump" key can clear command. To prevent accidental control. + if train.tarvelocity or train.atc_command then + return + end + if pc.up then + train.ctrl.user=4 + act=true + end if pc.down then if train.velocity>0 then if pc.jump then @@ -81,9 +85,6 @@ function advtrains.on_control_change(pc, train, flip) if not act then train.ctrl.user = nil end - if pc.aux1 then - --horn - end end end function advtrains.update_driver_hud(pname, train, flip) -- cgit v1.2.3