mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
minetest.after(): simplify further, pause in singleplayer (#5500)
Using the `dtime` value entirely, this will stop the clock if the game is paused in singleplayer. Since most of the clocks were fixed a long time ago, this should again be safe to use.
This commit is contained in:
parent
26f4a5c2d1
commit
75fb3e4730
1 changed files with 1 additions and 11 deletions
|
@ -1,18 +1,8 @@
|
||||||
local jobs = {}
|
local jobs = {}
|
||||||
local time = 0.0
|
local time = 0.0
|
||||||
local last = core.get_us_time() / 1000000
|
|
||||||
|
|
||||||
core.register_globalstep(function(dtime)
|
core.register_globalstep(function(dtime)
|
||||||
local new = core.get_us_time() / 1000000
|
time = time + dtime
|
||||||
if new > last then
|
|
||||||
time = time + (new - last)
|
|
||||||
else
|
|
||||||
-- Overflow, we may lose a little bit of time here but
|
|
||||||
-- only 1 tick max, potentially running timers slightly
|
|
||||||
-- too early.
|
|
||||||
time = time + new
|
|
||||||
end
|
|
||||||
last = new
|
|
||||||
|
|
||||||
if #jobs < 1 then
|
if #jobs < 1 then
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue