update
This commit is contained in:
parent
a9bba98e20
commit
c0ae3551fe
13 changed files with 235 additions and 62 deletions
|
@ -75,6 +75,13 @@ advtrains.register_wagon(name, prototype, description, inventory_image)
|
||||||
^- Getting on by walking in then takes effect.
|
^- Getting on by walking in then takes effect.
|
||||||
^- Positive values mean front, negative ones back. Resulting position is automatically shifted to the right side.
|
^- Positive values mean front, negative ones back. Resulting position is automatically shifted to the right side.
|
||||||
|
|
||||||
|
coupler_types_front = {scharfenberg=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
|
^- Defines the available coupler types on this wagon on the front and back side. Wagon will only couple to wagons that have a matching coupler. (this property does not have any visual impact)
|
||||||
|
^- Default: not given (nil) - causes the wagon to couple to any other wagon regardless of coupler type.
|
||||||
|
^- Empty table ({}): This wagon does not couple to any other wagon (e.g. for Linetrack vehicles)
|
||||||
|
^- Register coupler types using ''advtrains.register_coupler_type(type, name)''. advtrains defines the default types "chain" (Buffer and Chain) and "scharfenberg" (Scharfenberg coupler).
|
||||||
|
|
||||||
wagon_span=2,
|
wagon_span=2,
|
||||||
^- How far this wagon extends from its base position. Is the half of the wagon length.
|
^- How far this wagon extends from its base position. Is the half of the wagon length.
|
||||||
^- Used to determine in which distance the other wagons have to be positioned. Will require tweaking.
|
^- Used to determine in which distance the other wagons have to be positioned. Will require tweaking.
|
||||||
|
|
|
@ -199,10 +199,16 @@ local matchptn={
|
||||||
return #match+1
|
return #match+1
|
||||||
end,
|
end,
|
||||||
["B([0-9]+)"]=function(id, train, match)
|
["B([0-9]+)"]=function(id, train, match)
|
||||||
if train.velocity>tonumber(match) then
|
local btar = tonumber(match)
|
||||||
train.atc_brake_target=tonumber(match)
|
if train.velocity>btar then
|
||||||
if not train.tarvelocity or train.tarvelocity>train.atc_brake_target then
|
train.atc_brake_target=btar
|
||||||
train.tarvelocity=train.atc_brake_target
|
if not train.tarvelocity or train.tarvelocity>btar then
|
||||||
|
train.tarvelocity=btar
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- independent of brake target, must make sure that tarvelocity is not greater than it
|
||||||
|
if train.tarvelocity and train.tarvelocity>btar then
|
||||||
|
train.tarvelocity=btar
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return #match+1
|
return #match+1
|
||||||
|
@ -267,6 +273,10 @@ local matchptn={
|
||||||
advtrains.interlocking.ars_set_disable(train, match=="0")
|
advtrains.interlocking.ars_set_disable(train, match=="0")
|
||||||
return 2
|
return 2
|
||||||
end,
|
end,
|
||||||
|
["Cpl"]=function(id, train)
|
||||||
|
train.atc_wait_autocouple=true
|
||||||
|
return 3
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
eval_conditional = function(command, arrow, speed)
|
eval_conditional = function(command, arrow, speed)
|
||||||
|
@ -358,11 +368,13 @@ function atc.execute_atc_command(id, train)
|
||||||
local match=string.match(command, "^"..pattern)
|
local match=string.match(command, "^"..pattern)
|
||||||
if match then
|
if match then
|
||||||
local patlen=func(id, train, match)
|
local patlen=func(id, train, match)
|
||||||
|
--atdebug("Executing: "..string.sub(command, 1, patlen))
|
||||||
atprint("Executing: "..string.sub(command, 1, patlen))
|
--atdebug("Train ATC State: tvel=",train.tarvelocity,"brktar=",train.atc_brake_target,"delay=",train.atc_delay,"wfinish=",train.atc_wait_finish,"wacpl=",train.atc_wait_autocouple)
|
||||||
|
|
||||||
train.atc_command=string.sub(command, patlen+1)
|
train.atc_command=string.sub(command, patlen+1)
|
||||||
if train.atc_delay<=0 and not train.atc_wait_finish then
|
if train.atc_delay<=0
|
||||||
|
and not train.atc_wait_finish
|
||||||
|
and not train.atc_wait_autocouple then
|
||||||
--continue (recursive, cmds shouldn't get too long, and it's a end-recursion.)
|
--continue (recursive, cmds shouldn't get too long, and it's a end-recursion.)
|
||||||
atc.execute_atc_command(id, train)
|
atc.execute_atc_command(id, train)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,17 +11,24 @@
|
||||||
-- When the initiating train has autocouple set, trains are immediately coupled
|
-- When the initiating train has autocouple set, trains are immediately coupled
|
||||||
-- When not, a couple entity is spawned and coupling commences on click
|
-- When not, a couple entity is spawned and coupling commences on click
|
||||||
-- Coupling MUST preserve the train ID of the initiating train, so it is done like this:
|
-- Coupling MUST preserve the train ID of the initiating train, so it is done like this:
|
||||||
-- initiating train is reversed
|
|
||||||
-- stationary train is reversed if required, so that it points towards the initiating train
|
|
||||||
-- do_connect_trains(initiating, stationary)
|
|
||||||
-- As a result, the coupled train is reversed in direction. Alternative way of doing things (might be considered later):
|
|
||||||
-- stationary train is reversed if required, so that it points away from the initiating train
|
|
||||||
-- index of initiating train is set so that it matches the front pos of stationary train
|
-- index of initiating train is set so that it matches the front pos of stationary train
|
||||||
-- wagons of stationary train are inserted at the beginning of initiating train
|
|
||||||
-- remove stationary train
|
-- remove stationary train
|
||||||
|
-- wagons of stationary train are inserted at the beginning of initiating train (considers direction of stat_train and inserts reverse if required)
|
||||||
|
|
||||||
-- train.couple_* contain references to ObjectRefs of couple objects, which contain all relevant information
|
-- train.couple_* contain references to ObjectRefs of couple objects, which contain all relevant information
|
||||||
-- These objectRefs will delete themselves once the couples no longer match (see below)
|
-- These objectRefs will delete themselves once the couples no longer match (see below)
|
||||||
|
|
||||||
|
advtrains.coupler_types = {}
|
||||||
|
|
||||||
|
function advtrains.register_coupler_type(code, name)
|
||||||
|
advtrains.coupler_types[code] = name
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Register some default couplers
|
||||||
|
advtrains.register_coupler_type("chain", attrans("Buffer and Chain Coupler"))
|
||||||
|
advtrains.register_coupler_type("scharfenberg", attrans("Scharfenberg Coupler"))
|
||||||
|
|
||||||
|
|
||||||
local function create_couple_entity(pos, train1, t1_is_front, train2, t2_is_front)
|
local function create_couple_entity(pos, train1, t1_is_front, train2, t2_is_front)
|
||||||
local id1 = train1.id
|
local id1 = train1.id
|
||||||
local id2 = train2.id
|
local id2 = train2.id
|
||||||
|
@ -142,14 +149,22 @@ end
|
||||||
-- Called from train_step_b() when the current train (init_train) just stopped at one of the end indices of another train (stat_train)
|
-- Called from train_step_b() when the current train (init_train) just stopped at one of the end indices of another train (stat_train)
|
||||||
-- Depending on autocouple, either couples immediately or spawns a couple entity
|
-- Depending on autocouple, either couples immediately or spawns a couple entity
|
||||||
function advtrains.couple_initiate_with(init_train, stat_train, stat_is_front)
|
function advtrains.couple_initiate_with(init_train, stat_train, stat_is_front)
|
||||||
--atdebug("Initiating couplign between init=",init_train.id,"stat=",stat_train.id,"backside=",stat_is_backside)
|
--atdebug("Couple init autocouple=",init_train.autocouple,"atc_w_acpl=",init_train.atc_wait_autocouple)
|
||||||
if init_train.autocouple then
|
if init_train.autocouple or init_train.atc_wait_autocouple then
|
||||||
advtrains.couple_trains(init_train, true, stat_train, stat_is_front)
|
local cplmatch, msg = advtrains.check_matching_coupler_types(init_train, true, stat_train, stat_is_front)
|
||||||
else
|
if cplmatch then
|
||||||
local pos = advtrains.path_get_interpolated(init_train, init_train.index)
|
advtrains.couple_trains(init_train, false, stat_train, stat_is_front)
|
||||||
create_couple_entity(pos, init_train, true, stat_train, stat_is_front)
|
-- clear atc couple waiting blocker
|
||||||
|
init_train.atc_wait_autocouple = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
-- get here if either autocouple is not on or couples dont match
|
||||||
|
local pos = advtrains.path_get_interpolated(init_train, init_train.index)
|
||||||
|
create_couple_entity(pos, init_train, true, stat_train, stat_is_front)
|
||||||
|
-- clear ATC command on collision
|
||||||
|
advtrains.atc.train_reset_command(init_train)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check if the player has permission for the first/last wagon of the train
|
-- check if the player has permission for the first/last wagon of the train
|
||||||
|
@ -177,54 +192,145 @@ function advtrains.safe_couple_trains(train1, t1_is_front, train2, t2_is_front,
|
||||||
wck_t2 = check_twagon_owner(train2, t2_is_front, pname)
|
wck_t2 = check_twagon_owner(train2, t2_is_front, pname)
|
||||||
end
|
end
|
||||||
if (wck_t1 or wck_t2) or not pname then
|
if (wck_t1 or wck_t2) or not pname then
|
||||||
advtrains.couple_trains(train1, t1_is_front, train2, t2_is_front)
|
|
||||||
|
local cplmatch, msg = advtrains.check_matching_coupler_types(train1, t1_is_front, train2, t2_is_front)
|
||||||
|
if cplmatch then
|
||||||
|
advtrains.couple_trains(train1, not t1_is_front, train2, t2_is_front)
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(pname, msg)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Actually performs the train coupling. Always retains train ID of train1
|
-- Actually performs the train coupling. Always retains train ID of train1
|
||||||
function advtrains.couple_trains(train1, t1_is_front, train2, t2_is_front)
|
function advtrains.couple_trains(init_train, invert_init_train, stat_train, stat_train_opposite)
|
||||||
--atdebug("Couple trains init=",init_train.id,"stat=",stat_train.id,"statreverse=",stat_must_reverse)
|
--atdebug("Couple trains init=",init_train.id,"initinv=",invert_init_train,"stat=",stat_train.id,"statreverse=",stat_train_opposite)
|
||||||
-- see comment on top of file
|
|
||||||
if t1_is_front then
|
|
||||||
advtrains.invert_train(train1.id)
|
|
||||||
end
|
|
||||||
if not t2_is_front then
|
|
||||||
advtrains.invert_train(train2.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
advtrains.do_connect_trains(train1, train2)
|
if not advtrains.train_ensure_init(init_train.id, init_train) then
|
||||||
end
|
atwarn("Coupling: initiating train",init_train.id,"is not initialized! Operation aborted!")
|
||||||
|
|
||||||
-- Adds the wagons of first to second and deletes second_id afterwards
|
|
||||||
-- Assumes that second_id stands right behind first_id and both trains point to the same direction
|
|
||||||
function advtrains.do_connect_trains(first, second)
|
|
||||||
|
|
||||||
if not advtrains.train_ensure_init(first.id, first) then
|
|
||||||
atwarn("Coupling: first train",first.id,"is not initialized! Operation aborted!")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not advtrains.train_ensure_init(second.id, second) then
|
if not advtrains.train_ensure_init(stat_train.id, stat_train) then
|
||||||
atwarn("Coupling: second train",second.id,"is not initialized! Operation aborted!")
|
atwarn("Coupling: stationary train",stat_train.id,"is not initialized! Operation aborted!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local first_wagoncnt=#first.trainparts
|
|
||||||
local second_wagoncnt=#second.trainparts
|
|
||||||
|
|
||||||
for _,v in ipairs(second.trainparts) do
|
|
||||||
table.insert(first.trainparts, v)
|
|
||||||
end
|
|
||||||
|
|
||||||
advtrains.remove_train(second.id)
|
|
||||||
|
|
||||||
first.velocity = 0
|
-- only used with the couple entity
|
||||||
|
if invert_init_train then
|
||||||
|
advtrains.invert_train(init_train.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
local itp = init_train.trainparts
|
||||||
|
local init_wagoncnt = #itp
|
||||||
|
local stp = stat_train.trainparts
|
||||||
|
local stat_wagoncnt = #stp
|
||||||
|
local stat_trainlen = stat_train.trainlen -- save the train length of stat train, to be added to index
|
||||||
|
|
||||||
|
if stat_train_opposite then
|
||||||
|
-- insert wagons in inverse order and set their wagon_flipped state
|
||||||
|
for i=1,stat_wagoncnt do
|
||||||
|
table.insert(itp, 1, stp[i])
|
||||||
|
local wdata = advtrains.wagons[stp[i]]
|
||||||
|
if wdata then
|
||||||
|
wdata.wagon_flipped = not wdata.wagon_flipped
|
||||||
|
else
|
||||||
|
atwarn("While coupling, wagon",stp[i],"of stationary train",stat_train.id,"not found!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
--insert wagons in normal order
|
||||||
|
for i=stat_wagoncnt,1,-1 do
|
||||||
|
table.insert(itp, 1, stp[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: migrate some of the properties from stat_train to init_train?
|
||||||
|
|
||||||
advtrains.update_trainpart_properties(first.id)
|
advtrains.remove_train(stat_train.id)
|
||||||
advtrains.couple_invalidate(first)
|
|
||||||
|
-- Set train index forward
|
||||||
|
init_train.index = advtrains.path_get_index_by_offset(init_train, init_train.index, stat_trainlen)
|
||||||
|
|
||||||
|
advtrains.update_trainpart_properties(init_train.id)
|
||||||
|
advtrains.couple_invalidate(init_train)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Couple types matching check
|
||||||
|
-- returns: true, nil if OK
|
||||||
|
-- false, errmsg if there is an error
|
||||||
|
function advtrains.check_matching_coupler_types(t1, t1_front, t2, t2_front)
|
||||||
|
-- 1. get wagons
|
||||||
|
local t1_wid
|
||||||
|
if t1_front then
|
||||||
|
t1_wid = t1.trainparts[1]
|
||||||
|
else
|
||||||
|
t1_wid = t1.trainparts[#t1.trainparts]
|
||||||
|
end
|
||||||
|
local t2_wid
|
||||||
|
if t2_front then
|
||||||
|
t2_wid = t2.trainparts[1]
|
||||||
|
else
|
||||||
|
t2_wid = t2.trainparts[#t2.trainparts]
|
||||||
|
end
|
||||||
|
|
||||||
|
--atdebug("CMCT: t1_wid",t1_wid,"t2_wid",t2_wid,"")
|
||||||
|
|
||||||
|
if not t1_wid or not t2_wid then
|
||||||
|
return false, "Unable to retrieve wagons from train"--note: no translation needed, case should not occur
|
||||||
|
end
|
||||||
|
|
||||||
|
local t1_wagon = advtrains.wagons[t1_wid]
|
||||||
|
local t2_wagon = advtrains.wagons[t2_wid]
|
||||||
|
|
||||||
|
if not t1_wagon or not t2_wagon then
|
||||||
|
return false, "At least one of wagons "..t1_wagon.." or "..t2_wagon.." does not exist"--note: no translation needed, case should not occur
|
||||||
|
end
|
||||||
|
|
||||||
|
-- these calls do not fail, they may return placeholder - doesn't matter
|
||||||
|
local _,t1_wpro = advtrains.get_wagon_prototype(t1_wagon)
|
||||||
|
local _,t2_wpro = advtrains.get_wagon_prototype(t2_wagon)
|
||||||
|
|
||||||
|
-- get correct couplers table (front/back)
|
||||||
|
local t1_cplt
|
||||||
|
if not t1_front == not t1_wagon.wagon_flipped then --fancy XOR
|
||||||
|
t1_cplt = t1_wpro.coupler_types_back
|
||||||
|
else
|
||||||
|
t1_cplt = t1_wpro.coupler_types_front
|
||||||
|
end
|
||||||
|
local t2_cplt
|
||||||
|
if not t2_front == not t2_wagon.wagon_flipped then --fancy XOR
|
||||||
|
t2_cplt = t2_wpro.coupler_types_back
|
||||||
|
else
|
||||||
|
t2_cplt = t2_wpro.coupler_types_front
|
||||||
|
end
|
||||||
|
|
||||||
|
--atdebug("CMCT: t1",t1_cplt,"t2",t2_cplt,"")
|
||||||
|
|
||||||
|
-- if at least one of the trains has no couplers table, it always couples (fallback behavior and mode for universal shunters)
|
||||||
|
if not t1_cplt or not t2_cplt then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- have common coupler?
|
||||||
|
for typ,_ in pairs(t1_cplt) do
|
||||||
|
if t2_cplt[typ] then
|
||||||
|
--atdebug("CMCT: Matching type",typ)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--no match, give user an info
|
||||||
|
local t1_cplhr, t2_cplhr = {},{}
|
||||||
|
for typ,_ in pairs(t1_cplt) do
|
||||||
|
table.insert(t1_cplhr, advtrains.coupler_types[typ] or typ)
|
||||||
|
end
|
||||||
|
if #t1_cplhr==0 then t1_cplhr[1]=attrans("<none>") end
|
||||||
|
for typ,_ in pairs(t2_cplt) do
|
||||||
|
table.insert(t2_cplhr, advtrains.coupler_types[typ] or typ)
|
||||||
|
end
|
||||||
|
if #t2_cplhr==0 then t2_cplhr[1]=attrans("<none>") end
|
||||||
|
return false, attrans("Can not couple: The couplers of the trains do not match (@1 and @2).", table.concat(t1_cplhr, ","), table.concat(t2_cplhr, ","))
|
||||||
|
end
|
||||||
|
|
||||||
-- DECOUPLING --
|
-- DECOUPLING --
|
||||||
function advtrains.split_train_at_fc(train, count_empty, length_limit)
|
function advtrains.split_train_at_fc(train, count_empty, length_limit)
|
||||||
|
|
|
@ -468,7 +468,7 @@ advtrains.avt_save = function(remove_players_from_wagons)
|
||||||
"atc_brake_target", "atc_wait_finish", "atc_command", "atc_delay", "door_open",
|
"atc_brake_target", "atc_wait_finish", "atc_command", "atc_delay", "door_open",
|
||||||
"text_outside", "text_inside", "line", "routingcode",
|
"text_outside", "text_inside", "line", "routingcode",
|
||||||
"il_sections", "speed_restriction", "is_shunt",
|
"il_sections", "speed_restriction", "is_shunt",
|
||||||
"points_split", "autocouple", "ars_disable",
|
"points_split", "autocouple", "atc_wait_autocouple", "ars_disable",
|
||||||
})
|
})
|
||||||
--then save it
|
--then save it
|
||||||
tmp_trains[id]=v
|
tmp_trains[id]=v
|
||||||
|
|
|
@ -70,3 +70,8 @@ This track can not be removed!=Diese Schiene kann nicht entfernt werden!
|
||||||
Position is occupied by a train.=Ein Zug steht an dieser Position.
|
Position is occupied by a train.=Ein Zug steht an dieser Position.
|
||||||
There's a Track Circuit Break here.=Hier ist eine Gleisabschnittsgrenze (TCB).
|
There's a Track Circuit Break here.=Hier ist eine Gleisabschnittsgrenze (TCB).
|
||||||
There's a Signal Influence Point here.=Hier ist ein Signal-Beeinflussungspunkt.
|
There's a Signal Influence Point here.=Hier ist ein Signal-Beeinflussungspunkt.
|
||||||
|
Buffer and Chain Coupler=Schraubenkupplung
|
||||||
|
Scharfenberg Coupler=Scharfenbergkupplung
|
||||||
|
Japanese Train Inter-Wagon Connection=Waggonzwischenverbindung Japanischer Personenzug
|
||||||
|
Can not couple: The couplers of the trains do not match (@1 and @2).=Kann nicht ankuppeln: Die Kupplungen der Züge passen nicht zueinander (@1 und @2)
|
||||||
|
<none>=<keine>
|
||||||
|
|
|
@ -418,9 +418,11 @@ function advtrains.train_step_b(id, train, dtime)
|
||||||
ctrl_lever = userc
|
ctrl_lever = userc
|
||||||
else
|
else
|
||||||
if train.atc_command then
|
if train.atc_command then
|
||||||
if (not train.atc_delay or train.atc_delay<=0) and not train.atc_wait_finish then
|
if (not train.atc_delay or train.atc_delay<=0)
|
||||||
|
and not train.atc_wait_finish
|
||||||
|
and not train.atc_wait_autocouple then
|
||||||
advtrains.atc.execute_atc_command(id, train)
|
advtrains.atc.execute_atc_command(id, train)
|
||||||
else
|
elseif train.atc_delay and train.atc_delay > 0 then
|
||||||
train.atc_delay=train.atc_delay-dtime
|
train.atc_delay=train.atc_delay-dtime
|
||||||
end
|
end
|
||||||
elseif train.atc_delay then
|
elseif train.atc_delay then
|
||||||
|
@ -711,12 +713,15 @@ function advtrains.train_step_c(id, train, dtime)
|
||||||
if train.ontrack_collision_info then
|
if train.ontrack_collision_info then
|
||||||
train.velocity = 0
|
train.velocity = 0
|
||||||
train.acceleration = 0
|
train.acceleration = 0
|
||||||
advtrains.atc.train_reset_command(train)
|
--advtrains.atc.train_reset_command(train) will occur in couple_initiate_with if required
|
||||||
|
|
||||||
local otrn = advtrains.trains[train.ontrack_collision_info.otid]
|
local otrn = advtrains.trains[train.ontrack_collision_info.otid]
|
||||||
|
|
||||||
if otrn.velocity == 0 then -- other train must be standing, else don't initiate coupling
|
if otrn.velocity == 0 then -- other train must be standing, else don't initiate coupling
|
||||||
advtrains.couple_initiate_with(train, otrn, not train.ontrack_collision_info.same_dir)
|
advtrains.couple_initiate_with(train, otrn, not train.ontrack_collision_info.same_dir)
|
||||||
|
else
|
||||||
|
-- other collision - stop any ATC control
|
||||||
|
advtrains.atc.train_reset_command(train)
|
||||||
end
|
end
|
||||||
|
|
||||||
train.ontrack_collision_info = nil
|
train.ontrack_collision_info = nil
|
||||||
|
|
|
@ -133,9 +133,11 @@ function advtrains.interlocking.ars_check(sigd, train)
|
||||||
local tcbs = il.db.get_tcbs(sigd)
|
local tcbs = il.db.get_tcbs(sigd)
|
||||||
if not tcbs or not tcbs.routes then return end
|
if not tcbs or not tcbs.routes then return end
|
||||||
|
|
||||||
if tcbs.ars_disabled then
|
if tcbs.ars_disabled or tcbs.ars_ignore_next then
|
||||||
-- No-ARS mode of signal.
|
-- No-ARS mode of signal.
|
||||||
-- ignore...
|
-- ignore...
|
||||||
|
-- Note: ars_ignore_next is set by signalling formspec when route is cancelled
|
||||||
|
tcbs.ars_ignore_next = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -723,11 +723,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
connid = tonumber(connids)
|
connid = tonumber(connids)
|
||||||
if not connid or connid<1 or connid>2 then return end
|
if not connid or connid<1 or connid>2 then return end
|
||||||
end
|
end
|
||||||
if pos and connid and not fields.quit then
|
if pos and connid then
|
||||||
local sigd = {p=pos, s=connid}
|
local sigd = {p=pos, s=connid}
|
||||||
local tcbs = ildb.get_tcbs(sigd)
|
local tcbs = ildb.get_tcbs(sigd)
|
||||||
if not tcbs then return end
|
if not tcbs then return end
|
||||||
|
|
||||||
|
if fields.quit then
|
||||||
|
-- form quit: disable temporary ARS ignore
|
||||||
|
tcbs.ars_ignore_next = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local sel_rte
|
local sel_rte
|
||||||
if fields.rtelist then
|
if fields.rtelist then
|
||||||
local tev = minetest.explode_textlist_event(fields.rtelist)
|
local tev = minetest.explode_textlist_event(fields.rtelist)
|
||||||
|
@ -740,7 +746,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
end
|
end
|
||||||
if tcbs.routeset and fields.cancelroute then
|
if tcbs.routeset and fields.cancelroute then
|
||||||
if tcbs.routes[tcbs.routeset] and tcbs.routes[tcbs.routeset].ars then
|
if tcbs.routes[tcbs.routeset] and tcbs.routes[tcbs.routeset].ars then
|
||||||
tcbs.ars_disabled = true
|
tcbs.ars_ignore_next = true
|
||||||
end
|
end
|
||||||
-- if route committed, cancel route ts info
|
-- if route committed, cancel route ts info
|
||||||
ilrs.update_route(sigd, tcbs, nil, true)
|
ilrs.update_route(sigd, tcbs, nil, true)
|
||||||
|
@ -749,6 +755,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if fields.newroute and hasprivs then
|
if fields.newroute and hasprivs then
|
||||||
advtrains.interlocking.init_route_prog(pname, sigd)
|
advtrains.interlocking.init_route_prog(pname, sigd)
|
||||||
minetest.close_formspec(pname, formname)
|
minetest.close_formspec(pname, formname)
|
||||||
|
tcbs.ars_ignore_next = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if sel_rte and tcbs.routes[sel_rte] then
|
if sel_rte and tcbs.routes[sel_rte] then
|
||||||
|
|
|
@ -51,6 +51,10 @@ Kick all passengers out of the trains
|
||||||
This command kicks all passengers (non-driving players) off the train. This command works only
|
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.
|
if the train is stopped and its doors are open.
|
||||||
|
|
||||||
|
Cpl
|
||||||
|
Temporarily switch the train to "Autocouple" mode and wait for coupling.
|
||||||
|
This command makes the train continue at its current speed until it hits another standing wagon or train. Then, it couples to this train and ATC command execution continues.
|
||||||
|
|
||||||
# conditional statements:
|
# conditional statements:
|
||||||
|
|
||||||
I<condition><code>;
|
I<condition><code>;
|
||||||
|
|
|
@ -29,6 +29,8 @@ advtrains.register_wagon("engine_industrial", {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assign_to_seat_group = {"dstand"},
|
assign_to_seat_group = {"dstand"},
|
||||||
|
coupler_types_front = {chain=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=2.6,
|
wagon_span=2.6,
|
||||||
is_locomotive=true,
|
is_locomotive=true,
|
||||||
|
@ -66,6 +68,8 @@ advtrains.register_wagon("engine_industrial_big", {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assign_to_seat_group = {"dstand"},
|
assign_to_seat_group = {"dstand"},
|
||||||
|
coupler_types_front = {chain=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=4,
|
wagon_span=4,
|
||||||
is_locomotive=true,
|
is_locomotive=true,
|
||||||
|
@ -79,6 +83,8 @@ advtrains.register_wagon("wagon_tank", {
|
||||||
seats = {},
|
seats = {},
|
||||||
drives_on={default=true},
|
drives_on={default=true},
|
||||||
max_speed=20,
|
max_speed=20,
|
||||||
|
coupler_types_front = {chain=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=2.2,
|
wagon_span=2.2,
|
||||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||||
|
@ -95,6 +101,8 @@ advtrains.register_wagon("wagon_wood", {
|
||||||
seats = {},
|
seats = {},
|
||||||
drives_on={default=true},
|
drives_on={default=true},
|
||||||
max_speed=20,
|
max_speed=20,
|
||||||
|
coupler_types_front = {chain=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=1.8,
|
wagon_span=1.8,
|
||||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
local S = attrans
|
local S = attrans
|
||||||
|
|
||||||
|
-- note: scharfenberg coupler is defined in advtrains core
|
||||||
|
advtrains.register_coupler_type("train_japan_interwagon", attrans("Japanese Train Inter-Wagon Connection"))
|
||||||
|
|
||||||
advtrains.register_wagon("engine_japan", {
|
advtrains.register_wagon("engine_japan", {
|
||||||
mesh="advtrains_engine_japan.b3d",
|
mesh="advtrains_engine_japan.b3d",
|
||||||
textures = {"advtrains_engine_japan.png"},
|
textures = {"advtrains_engine_japan.png"},
|
||||||
|
@ -61,6 +64,8 @@ advtrains.register_wagon("engine_japan", {
|
||||||
[1]={frames={x=60, y=80}, time=1}
|
[1]={frames={x=60, y=80}, time=1}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
coupler_types_front = {scharfenberg=true},
|
||||||
|
coupler_types_back = {train_japan_interwagon=true},
|
||||||
door_entry={-1.7},
|
door_entry={-1.7},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=2.5,
|
wagon_span=2.5,
|
||||||
|
@ -131,6 +136,8 @@ advtrains.register_wagon("wagon_japan", {
|
||||||
[1]={frames={x=60, y=80}, time=1}
|
[1]={frames={x=60, y=80}, time=1}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
coupler_types_front = {train_japan_interwagon=true},
|
||||||
|
coupler_types_back = {train_japan_interwagon=true},
|
||||||
door_entry={-1.7, 1.7},
|
door_entry={-1.7, 1.7},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=2.3,
|
wagon_span=2.3,
|
||||||
|
|
|
@ -31,6 +31,8 @@ advtrains.register_wagon("newlocomotive", {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assign_to_seat_group = {"dstand"},
|
assign_to_seat_group = {"dstand"},
|
||||||
|
coupler_types_front = {chain=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=2.3,
|
wagon_span=2.3,
|
||||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||||
|
@ -100,6 +102,8 @@ advtrains.register_wagon("detailed_steam_engine", {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assign_to_seat_group = {"dstand"},
|
assign_to_seat_group = {"dstand"},
|
||||||
|
coupler_types_front = {chain=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=2.05,
|
wagon_span=2.05,
|
||||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||||
|
@ -193,6 +197,8 @@ advtrains.register_wagon("wagon_default", {
|
||||||
},
|
},
|
||||||
|
|
||||||
assign_to_seat_group = {"pass"},
|
assign_to_seat_group = {"pass"},
|
||||||
|
coupler_types_front = {chain=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=2.634,
|
wagon_span=2.634,
|
||||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||||
|
@ -206,6 +212,8 @@ advtrains.register_wagon("wagon_box", {
|
||||||
drives_on={default=true},
|
drives_on={default=true},
|
||||||
max_speed=10,
|
max_speed=10,
|
||||||
seats = {},
|
seats = {},
|
||||||
|
coupler_types_front = {chain=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=2,
|
wagon_span=2,
|
||||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||||
|
|
|
@ -51,6 +51,8 @@ advtrains.register_wagon("subway_wagon", {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assign_to_seat_group = {"pass", "dstand"},
|
assign_to_seat_group = {"pass", "dstand"},
|
||||||
|
coupler_types_front = {chain=true},
|
||||||
|
coupler_types_back = {chain=true},
|
||||||
doors={
|
doors={
|
||||||
open={
|
open={
|
||||||
[-1]={frames={x=0, y=20}, time=1},
|
[-1]={frames={x=0, y=20}, time=1},
|
||||||
|
|
Loading…
Reference in a new issue