2019-11-10 08:10:34 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local math, minetest, nodecore
|
|
|
|
= math, minetest, nodecore
|
|
|
|
local math_abs
|
|
|
|
= math.abs
|
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
2020-06-15 07:21:39 -04:00
|
|
|
nodecore.register_globalstep("gametime", function(dtime)
|
2019-11-10 08:10:34 -05:00
|
|
|
local mtt = minetest.get_gametime()
|
|
|
|
local nct = nodecore.gametime
|
|
|
|
if not nct then
|
2021-12-11 21:26:18 -05:00
|
|
|
nodecore.log("info", "nodecore.gametime: init to " .. mtt)
|
2019-11-10 08:10:34 -05:00
|
|
|
nct = mtt
|
|
|
|
end
|
|
|
|
nct = nct + dtime
|
|
|
|
if math_abs(nct - mtt) >= 2 then
|
2020-06-09 19:05:39 -04:00
|
|
|
nodecore.log("warning", "nodecore.gametime: excess drift; nct="
|
2019-11-10 08:10:34 -05:00
|
|
|
.. nct .. ", mtt=" .. mtt)
|
|
|
|
nct = mtt
|
|
|
|
end
|
|
|
|
nodecore.gametime = nct
|
|
|
|
end)
|