Make DTIME_LIMIT and SAVE_INTERVAL globally accessible
This commit is contained in:
parent
5569849401
commit
0bffd6ca64
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user