aboutsummaryrefslogtreecommitdiff
path: root/advtrains/init.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-01-02 20:23:09 +0100
committerorwell96 <orwell@bleipb.de>2021-02-10 16:39:46 +0100
commit080fbcf2fc1c39d76a82f73b7da0713b6f0fbc16 (patch)
treec403904b4a987c314a0b78ccb2628d07403ef478 /advtrains/init.lua
parent672b4a422cc6d4e9cb9bd9925a55e9a2127883f0 (diff)
downloadadvtrains-080fbcf2fc1c39d76a82f73b7da0713b6f0fbc16.tar.gz
advtrains-080fbcf2fc1c39d76a82f73b7da0713b6f0fbc16.tar.bz2
advtrains-080fbcf2fc1c39d76a82f73b7da0713b6f0fbc16.zip
Make dtime limiting a setting
Diffstat (limited to 'advtrains/init.lua')
-rw-r--r--advtrains/init.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua
index ea1330d..de06ef4 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -48,11 +48,11 @@ advtrains.IGNORE_WORLD = false
local NO_SAVE = false
-- Do not save any data to advtrains save files
--- Use a global slowdown factor to slow down train movements.
-local USE_SLOWDOWN = false
-local DTIME_LIMIT = 0.3
-- ==========================================================================
+-- Use a global slowdown factor to slow down train movements. Now a setting
+local DTIME_LIMIT = tonumber(minetest.settings:get("advtrains_dtime_limit")) or 0.2
+
--Constant for maximum connection value/division of the circle
AT_CMAX = 16
@@ -593,7 +593,7 @@ minetest.register_globalstep(function(dtime_mt)
t = os.clock()+HOW_MANY_LAG
end
-- if dtime is too high, decrease global slowdown
- if USE_SLOWDOWN then
+ if DTIME_LIMIT~=0 then
if dtime > DTIME_LIMIT then
if advtrains.global_slowdown > 0.1 then
advtrains.global_slowdown = advtrains.global_slowdown - 0.05
@@ -602,9 +602,9 @@ minetest.register_globalstep(function(dtime_mt)
end
dtime = DTIME_LIMIT
end
+ -- recover global slowdown slowly over time
+ advtrains.global_slowdown = math.min(advtrains.global_slowdown*1.02, 1)
end
- -- recover global slowdown slowly over time
- advtrains.global_slowdown = math.min(advtrains.global_slowdown*1.02, 1)
advtrains.mainloop_trainlogic(dtime,advtrains.mainloop_runcnt)
if advtrains_itm_mainloop then