Is there a way to stop minetest.register_globalstep?
- Andrey01
- Member
- Posts: 2579
- Joined: Wed Oct 19, 2016 15:18
- GitHub: Andrey2470T
- In-game: Andrey01
- Location: Russia, Moscow
Is there a way to stop minetest.register_globalstep?
Is there a way to stop minetest.register_globalstep call? It is infinte?
- ChimneySwift
- Member
- Posts: 320
- Joined: Fri Sep 22, 2017 06:46
- GitHub: ChimneySwift
- IRC: ChimneySwift
- In-game: ChimneySwift
- Location: 127.0.0.1
Re: Is there a way to stop minetest.register_globalstep?
Are you talking about a way to stop callbacks registered from other mods? Or by your own mod? If by your own mod it should be fairly simple:
This will run the globalstep for 10 seconds (approx. 100 iterations) then stop.
Code: Select all
runner = true
time = 0
minetest.register_globalstep(function(dtime)
time = time + dtime
if time >= 10 then
runner = false
end
if runner then
-- do stuff
end
end)
A spoon is basically a tiny bowl with a stick on it
- Andrey01
- Member
- Posts: 2579
- Joined: Wed Oct 19, 2016 15:18
- GitHub: Andrey2470T
- In-game: Andrey01
- Location: Russia, Moscow
Re: Is there a way to stop minetest.register_globalstep?
Thanks, ChimneySwift. That i needed.
Re: Is there a way to stop minetest.register_globalstep?
it's slightly more efficient to use `minetest.after()` if you do not need to run lua code every globalstep.
Code: Select all
local function work()
minetest.after(10, work) -- once every 10 seconds
-- do something
print("work done")
end
minetest.after(10, work)
Who is online
Users browsing this forum: Bing [Bot] and 10 guests