aboutsummaryrefslogtreecommitdiff
path: root/trainlogic.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-09-29 08:41:05 +0200
committerorwell96 <mono96.mml@gmail.com>2016-09-29 08:41:05 +0200
commit8b400329a03502b469f50bd30b2a8ae0429573ef (patch)
treeaaa7ed203eb9f94efecf87c4b8ff0f2eab6260bd /trainlogic.lua
parent76bd8eaabaf7a81d723e0db5d55004eadb343e92 (diff)
downloadadvtrains-8b400329a03502b469f50bd30b2a8ae0429573ef.tar.gz
advtrains-8b400329a03502b469f50bd30b2a8ae0429573ef.tar.bz2
advtrains-8b400329a03502b469f50bd30b2a8ae0429573ef.zip
add acceleration calculation
Diffstat (limited to 'trainlogic.lua')
-rw-r--r--trainlogic.lua5
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