aboutsummaryrefslogtreecommitdiff
path: root/advtrains/wagons.lua
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2021-01-07 23:58:05 +0100
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2021-01-07 23:58:05 +0100
commite9c76100a1f5ff474a4ed65555c3249b791bbf10 (patch)
treeb70910b94917a4d85f52aa1aaa9ddd0fe56b7a06 /advtrains/wagons.lua
parent8655eebc5fe8bf484ea2d96041b7b1bf70242e1b (diff)
downloadadvtrains-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/wagons.lua')
-rw-r--r--advtrains/wagons.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index ad4a5ab..5c8ac25 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -269,6 +269,15 @@ function wagon:destroy()
return true
end
+function wagon:is_driver_stand(seat)
+ if self.seat_groups then
+ return (seat.driving_ctrl_access or self.seat_groups[seat.group].driving_ctrl_access)
+ else
+ return seat.driving_ctrl_access
+ end
+
+end
+
function wagon:on_step(dtime)
return advtrains.pcall(function()
if not self:ensure_init() then return end
@@ -301,11 +310,7 @@ function wagon:on_step(dtime)
local pname=data.seatp[seatno]
local driver=pname and minetest.get_player_by_name(pname)
local has_driverstand = pname and advtrains.check_driving_couple_protection(pname, data.owner, data.whitelist)
- if self.seat_groups then
- has_driverstand = has_driverstand and (seat.driving_ctrl_access or self.seat_groups[seat.group].driving_ctrl_access)
- else
- has_driverstand = has_driverstand and (seat.driving_ctrl_access)
- end
+ has_driverstand = has_driverstand and self:is_driver_stand(seat)
if has_driverstand and driver then
advtrains.update_driver_hud(driver:get_player_name(), self:train(), data.wagon_flipped)
elseif driver then