Long delay in minetest.after call, compared to globalstep

Post Reply
Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Long delay in minetest.after call, compared to globalstep

by Byakuren » Post

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: https://github.com/raymoo/magical_realm ... t.lua#L272

Here is the minetest.after call: http://repo.or.cz/minetest_playereffect ... t.lua#l199

Here is the globalstep callback: repo.or.cz/minetest_playereffects.git/blob/HEAD:/init.lua#l405

I tried adding a line to print the duration right before it is passed to minetest.after, and it appears to be correct.
Every time a mod API is left undocumented, a koala dies.

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

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

by Byakuren » Post

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.
Every time a mod API is left undocumented, a koala dies.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests