aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-06-29 01:30:27 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-06-29 01:30:27 +0200
commit0b14d8ddb131343a588f27b8c06f1742036d00a7 (patch)
treefcce867b15622073bb84de0fbf079e1e0c0c616d /advtrains
parentf458f39fde62432cae0829974b37ac72d3c3dbce (diff)
downloadadvtrains-0b14d8ddb131343a588f27b8c06f1742036d00a7.tar.gz
advtrains-0b14d8ddb131343a588f27b8c06f1742036d00a7.tar.bz2
advtrains-0b14d8ddb131343a588f27b8c06f1742036d00a7.zip
Add autocouple mode
The shunting mode no longer makes trains couple, since it was meant for other purposes. For autocoupling, the new autocoupling mode is used. If trains are in autocouple mode, they couple when they collide with another train.
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/init.lua2
-rw-r--r--advtrains/trainlogic.lua8
2 files changed, 5 insertions, 5 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua
index bdb0bf9..0036037 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -392,7 +392,7 @@ advtrains.avt_save = function(remove_players_from_wagons)
"trainparts", "recently_collided_with_env",
"atc_brake_target", "atc_wait_finish", "atc_command", "atc_delay", "door_open",
"text_outside", "text_inside", "line", "routingcode",
- "il_sections", "speed_restriction", "is_shunt", "points_split",
+ "il_sections", "speed_restriction", "is_shunt", "points_split", "autocouple"
})
--then save it
tmp_trains[id]=v
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 1ae96bd..6155768 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -906,7 +906,7 @@ function advtrains.split_train_at_index(train, index)
atwarn("Train",train_id,"is not initialized! Operation aborted!")
return
end
- train.is_shunt = nil -- prevent immediate recoupling
+
local p_index=advtrains.path_get_index_by_offset(train, train.index, - data.pos_in_train + wagon.wagon_span)
local pos, connid, frac = advtrains.path_getrestore(train, p_index)
local tp = {}
@@ -944,10 +944,10 @@ local CPL_ZONE = 2
local function createcouple(pos, train1, t1_is_front, train2, t2_is_front)
local id1 = train1.id
local id2 = train2.id
- if train1.is_shunt or train2.is_shunt then
+ if train1.autocouple or train2.autocouple then
-- couple trains
- train1.is_shunt = nil
- train2.is_shunt = nil
+ train1.autocouple = nil
+ train2.autocouple = nil
minetest.after(0, advtrains.safe_couple_trains, id1, id2, t1_is_front, t2_is_front, false, false, train1.velocity, train2.velocity)
return
end