From 0bffd6ca647e3a332e66555e1a5d9866442cf6ef Mon Sep 17 00:00:00 2001 From: orwell96 Date: Mon, 15 Feb 2021 19:41:13 +0100 Subject: Make DTIME_LIMIT and SAVE_INTERVAL globally accessible --- advtrains/init.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/advtrains/init.lua b/advtrains/init.lua index 2e10530..7cc0ccd 100644 --- a/advtrains/init.lua +++ b/advtrains/init.lua @@ -51,8 +51,8 @@ local NO_SAVE = false -- ========================================================================== -- 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 -local SAVE_INTERVAL = tonumber(minetest.settings:get("advtrains_save_interval")) or 60 +advtrains.DTIME_LIMIT = tonumber(minetest.settings:get("advtrains_dtime_limit")) or 0.2 +advtrains.SAVE_INTERVAL = tonumber(minetest.settings:get("advtrains_save_interval")) or 60 --Constant for maximum connection value/division of the circle AT_CMAX = 16 @@ -564,7 +564,7 @@ end --## MAIN LOOP ##-- --Calls all subsequent main tasks of both advtrains and atlatc local init_load=false -local save_timer = SAVE_INTERVAL +local save_timer = advtrains.SAVE_INTERVAL advtrains.mainloop_runcnt=0 advtrains.global_slowdown = 1 @@ -592,14 +592,14 @@ minetest.register_globalstep(function(dtime_mt) t = os.clock()+HOW_MANY_LAG end -- if dtime is too high, decrease global slowdown - if DTIME_LIMIT~=0 then - if dtime > DTIME_LIMIT then + if advtrains.DTIME_LIMIT~=0 then + if dtime > advtrains.DTIME_LIMIT then if advtrains.global_slowdown > 0.1 then advtrains.global_slowdown = advtrains.global_slowdown - 0.05 else advtrains.global_slowdown = advtrains.global_slowdown / 2 end - dtime = DTIME_LIMIT + dtime = advtrains.DTIME_LIMIT end -- recover global slowdown slowly over time advtrains.global_slowdown = math.min(advtrains.global_slowdown*1.02, 1) @@ -623,7 +623,7 @@ minetest.register_globalstep(function(dtime_mt) local t=os.clock() --save advtrains.save() - save_timer = SAVE_INTERVAL + save_timer = advtrains.SAVE_INTERVAL atprintbm("saving", t) end end) -- cgit v1.2.3