From be1ac1e68ed41945d0dfa68148186856497f2936 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 21 Feb 2017 11:39:13 +0100 Subject: Fix collision issues --- advtrains.zip | Bin 5123609 -> 5122842 bytes advtrains/advtrains/couple.lua | 2 +- advtrains/advtrains/trainlogic.lua | 68 ++++++++++++------------------------- 3 files changed, 22 insertions(+), 48 deletions(-) diff --git a/advtrains.zip b/advtrains.zip index f7e9e1b..6348ab3 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/advtrains/advtrains/couple.lua b/advtrains/advtrains/couple.lua index 7a1e07a..8697226 100644 --- a/advtrains/advtrains/couple.lua +++ b/advtrains/advtrains/couple.lua @@ -144,7 +144,7 @@ minetest.register_entity("advtrains:couple", { else tp2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) end - if not tp1 or not tp2 or not (vector.distance(tp1,tp2)<1.5) then + if not tp1 or not tp2 or not (vector.distance(tp1,tp2)<2) then self.object:remove() return else diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index 8543b26..3f72750 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -378,6 +378,11 @@ function advtrains.train_step_a(id, train, dtime) if ifn>ifo then for i=ifo+1, ifn do if path[i] then + local pts=minetest.pos_to_string(path[i]) + if advtrains.detector.on_node[pts] and advtrains.detector.on_node[pts]~=id then + --if another train has signed up for this position first, it won't be recognized in train_step_b. So do collision here. + advtrains.collide_and_spawn_couple(id, path[i], advtrains.detector.on_node[pts], false) + end advtrains.detector.enter_node(path[i], id) end end @@ -391,6 +396,11 @@ function advtrains.train_step_a(id, train, dtime) if ibn