aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/api_doc.txt5
-rw-r--r--advtrains/init.lua7
2 files changed, 12 insertions, 0 deletions
diff --git a/advtrains/api_doc.txt b/advtrains/api_doc.txt
index 7bd9c44..d16a611 100644
--- a/advtrains/api_doc.txt
+++ b/advtrains/api_doc.txt
@@ -178,5 +178,10 @@ minetest.register_node(nodename, {
^- called when a train enters the rail
on_train_leave=function(pos, train_id) end
^- called when a train leaves the rail
+
+ -- The following function is only in effect when interlocking is enabled:
+ on_train_approach = function(pos, train_id, train, index)
+ ^- called when a train is approaching this position, called exactly once for every path recalculation (which can happen at any time)
+ ^- This is called so that if the train would start braking now, it would come to halt about(wide approx) 5 nodes before the rail.
}
})
diff --git a/advtrains/init.lua b/advtrains/init.lua
index 9d20722..5d1af41 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -194,6 +194,9 @@ dofile(advtrains.modpath.."/passive.lua")
--load/save
+-- backup variables, used if someone should accidentally delete a sub-mod
+local MDS_interlocking
+
advtrains.fpath=minetest.get_worldpath().."/advtrains"
dofile(advtrains.modpath.."/log.lua")
@@ -219,6 +222,8 @@ function advtrains.avt_load()
advtrains.atc.load_data(tbl.atc)
if advtrains.interlocking then
advtrains.interlocking.db.load(tbl.interlocking)
+ else
+ MDS_interlocking = tbl.interlocking
end
--remove wagon_save entries that are not part of a train
local todel=advtrains.merge_tables(advtrains.wagon_save)
@@ -318,6 +323,8 @@ advtrains.avt_save = function(remove_players_from_wagons)
local il_save
if advtrains.interlocking then
il_save = advtrains.interlocking.db.save()
+ else
+ il_save = MDS_interlocking
end
local save_tbl={
trains = tmp_trains,