diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2021-01-07 23:58:05 +0100 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2021-01-07 23:58:05 +0100 |
commit | e9c76100a1f5ff474a4ed65555c3249b791bbf10 (patch) | |
tree | b70910b94917a4d85f52aa1aaa9ddd0fe56b7a06 /advtrains/atc.lua | |
parent | 8655eebc5fe8bf484ea2d96041b7b1bf70242e1b (diff) | |
download | advtrains-e9c76100a1f5ff474a4ed65555c3249b791bbf10.tar.gz advtrains-e9c76100a1f5ff474a4ed65555c3249b791bbf10.tar.bz2 advtrains-e9c76100a1f5ff474a4ed65555c3249b791bbf10.zip |
Add ATC "K" command
This command kicks out all passengers when the train is stopped and
its doors are open. In addtion, a wagon:is_driver_stand(seat) function
was added to allow finding out easily if a seat is the driver stand of
the wagon.
Diffstat (limited to 'advtrains/atc.lua')
-rw-r--r-- | advtrains/atc.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/advtrains/atc.lua b/advtrains/atc.lua index 20f52b9..2fa3929 100644 --- a/advtrains/atc.lua +++ b/advtrains/atc.lua @@ -230,6 +230,32 @@ local matchptn={ train.door_open = tt[match]*arr return 2 end, + ["K"] = function(id, train) + if train.door_open == 0 then + atwarn(sid(id), attrans("ATC Kick command warning: Doors closed")) + return 1 + end + if train.velocity > 0 then + atwarn(sid(id), attrans("ATC Kick command warning: Train moving")) + return 1 + end + local tp = train.trainparts + for i=1,#tp do + local data = advtrains.wagons[tp[i]] + local obj = advtrains.wagon_objects[tp[i]] + if data and obj then + local ent = obj:get_luaentity() + if ent then + for seatno,seat in pairs(ent.seats) do + if data.seatp[seatno] and not ent:is_driver_stand(seat) then + ent:get_off(seatno) + end + end + end + end + end + return 1 + end, } eval_conditional = function(command, arrow, speed) |