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.
This commit is contained in:
parent
8655eebc5f
commit
e9c76100a1
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -46,6 +46,11 @@ Example:
|
|||
B0 W OL D10 OC D1 SM
|
||||
Subway train: stop in station and open doors, depart after 10 seconds.
|
||||
|
||||
K
|
||||
Kick all passengers out of the trains
|
||||
This command kicks all passengers (non-driving players) off the train. This command works only
|
||||
if the train is stopped and its doors are open.
|
||||
|
||||
# conditional statements:
|
||||
|
||||
I<condition><code>;
|
||||
|
|
Loading…
Reference in New Issue