aboutsummaryrefslogtreecommitdiff
path: root/advtrains/init.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-01-23 15:35:58 +0100
committerorwell96 <orwell@bleipb.de>2019-01-23 15:37:18 +0100
commit1c3ea960415fcbd63c5f1b2cd8a5b25f79d2879f (patch)
tree2dffb9f8ad35c7eac66752a405f1796a23eba2fe /advtrains/init.lua
parentf6f922c90cfc2c5795110a5b2c0bdbee927a67ed (diff)
downloadadvtrains-1c3ea960415fcbd63c5f1b2cd8a5b25f79d2879f.tar.gz
advtrains-1c3ea960415fcbd63c5f1b2cd8a5b25f79d2879f.tar.bz2
advtrains-1c3ea960415fcbd63c5f1b2cd8a5b25f79d2879f.zip
Possible fix for braking problems + debug outputs
Diffstat (limited to 'advtrains/init.lua')
-rw-r--r--advtrains/init.lua24
1 files changed, 19 insertions, 5 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua
index cc54c02..21b414e 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -12,6 +12,7 @@ end
--advtrains
DUMP_DEBUG_SAVE = false
+GENERATE_ATRICIFIAL_LAG = false
--Constant for maximum connection value/division of the circle
AT_CMAX = 16
@@ -365,6 +366,8 @@ local save_interval=20
local save_timer=save_interval
advtrains.mainloop_runcnt=0
+
+local t = 0
minetest.register_globalstep(function(dtime_mt)
return advtrains.pcall(function()
advtrains.mainloop_runcnt=advtrains.mainloop_runcnt+1
@@ -373,11 +376,22 @@ minetest.register_globalstep(function(dtime_mt)
if not init_load then
advtrains.load()
end
- --limit dtime: if trains move too far in one step, automation may cause stuck and wrongly braking trains
- local dtime=dtime_mt
- if dtime>0.2 then
- atprint("Limiting dtime to 0.2!")
- dtime=0.2
+
+ local dtime
+ if GENERATE_ATRICIFIAL_LAG then
+ dtime = 0.2
+ if os.clock()<t then
+ return
+ end
+
+ t = os.clock()+0.2
+ else
+ --limit dtime: if trains move too far in one step, automation may cause stuck and wrongly braking trains
+ dtime=dtime_mt
+ if dtime>0.2 then
+ atprint("Limiting dtime to 0.2!")
+ dtime=0.2
+ end
end
advtrains.mainloop_trainlogic(dtime)