Page 1 of 1

Long delay in minetest.after call, compared to globalstep

PostPosted: Mon Jan 04, 2016 22:48
by Byakuren
In my magical_realm modpack, I'm using playereffects effects to apply some effects to the player. playereffects, after applying an effect, calls minetest.after on a callback to cancel the effect, with the requested duration. Separately, the HUD of a player is updated on a globalstep, at intervals of one second. Usually, the HUD and effect cancellation are fairly in-sync, with the displayed time left going at most to a small negative number. But sometimes there are periods where the effect takes much longer to cancel, and the HUD continues to update, so that it might show -200 seconds left, for example.

I think I remember reading that minetest.after is also implemented using a globalstep callback. Why would the timing of the HUD and minetest.after action diverge so much?

Here is the effect in my code: ... t.lua#L272

Here is the minetest.after call: ... t.lua#l199

Here is the globalstep callback:

I tried adding a line to print the duration right before it is passed to minetest.after, and it appears to be correct.

Re: Long delay in minetest.after call, compared to globalste

PostPosted: Tue Jan 05, 2016 18:37
by Byakuren
Ok, I now see that the globalstep is actually using os.time to get the remaining times, so it would be possible for it to be out of sync if the server was lagging on global ticks.