aboutsummaryrefslogtreecommitdiff
path: root/trainlogic.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-08-22 23:28:25 +0200
committerorwell96 <mono96.mml@gmail.com>2016-08-22 23:28:25 +0200
commitc098b6ecdf21bd70092d3f3329abf713c90528b2 (patch)
tree18c7b89c4474717ce31468fe2e719503959e7af3 /trainlogic.lua
parent522a9ccd6818a14efe4886365e57b312d559d8db (diff)
downloadadvtrains-c098b6ecdf21bd70092d3f3329abf713c90528b2.tar.gz
advtrains-c098b6ecdf21bd70092d3f3329abf713c90528b2.tar.bz2
advtrains-c098b6ecdf21bd70092d3f3329abf713c90528b2.zip
finally fix train collisions (please work now)
Diffstat (limited to 'trainlogic.lua')
-rw-r--r--trainlogic.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/trainlogic.lua b/trainlogic.lua
index 1ec27e0..0afac7a 100644
--- a/trainlogic.lua
+++ b/trainlogic.lua
@@ -581,7 +581,7 @@ function advtrains.try_connect_trains_and_check_collision(id1, id2)
--local v2_sign = math.sign(i - ((train2.index-0.5) - ( (train2.index-0.5)-(advtrains.get_train_end_index(train2)+0.5) / 2 )))
--TODO physics
train1.velocity=1
- train2.velocity=advtrains.trains_facing(train1, train2) and -1 or 1
+ train2.velocity=advtrains.trains_facing(train1, train2) and 1 or -1
train1.recently_collided_with_env=true
train2.recently_collided_with_env=true
return
@@ -589,7 +589,7 @@ function advtrains.try_connect_trains_and_check_collision(id1, id2)
if vector.distance(testpos, frontpos1) < 0.5 then
--local v2_sign = math.sign(i - ((train2.index-0.5) - ( (train2.index-0.5)-(advtrains.get_train_end_index(train2)+0.5) / 2 )))
train1.velocity=-1
- train2.velocity=advtrains.trains_facing(train1, train2) and 1 or -1
+ train2.velocity=advtrains.trains_facing(train1, train2) and -1 or 1
train1.recently_collided_with_env=true
train2.recently_collided_with_env=true
return