diff options
author | orwell96 <mono96.mml@gmail.com> | 2016-09-29 08:41:05 +0200 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2016-09-29 08:41:05 +0200 |
commit | 8b400329a03502b469f50bd30b2a8ae0429573ef (patch) | |
tree | aaa7ed203eb9f94efecf87c4b8ff0f2eab6260bd /trainlogic.lua | |
parent | 76bd8eaabaf7a81d723e0db5d55004eadb343e92 (diff) | |
download | advtrains-8b400329a03502b469f50bd30b2a8ae0429573ef.tar.gz advtrains-8b400329a03502b469f50bd30b2a8ae0429573ef.tar.bz2 advtrains-8b400329a03502b469f50bd30b2a8ae0429573ef.zip |
add acceleration calculation
Diffstat (limited to 'trainlogic.lua')
-rw-r--r-- | trainlogic.lua | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/trainlogic.lua b/trainlogic.lua index 6e2b3c8..0291e8f 100644 --- a/trainlogic.lua +++ b/trainlogic.lua @@ -318,7 +318,10 @@ function advtrains.train_step(id, train, dtime) applydiff=(math.min((advtrains.train_brake_force*dtime), math.abs(diff))) end end - train.velocity=train.velocity+(applydiff*math.sign(train.tarvelocity-train.velocity)) + train.last_accel=(applydiff*math.sign(train.tarvelocity-train.velocity)) + train.velocity=train.velocity+train.last_accel + else + train.last_accel=0 end --move |