mapsave.lua 502 B

1234567891011121314151617181920212223
  1. local callbacks = {}
  2. local interval = tonumber(minetest.settings:get("server_map_save_interval"))
  3. assert(type(interval) == "number" and interval >= 0)
  4. assert(type(minetest.register_on_mapsave) == "nil")
  5. function minetest.register_on_mapsave(func)
  6. callbacks[#callbacks+1] = func
  7. end
  8. local timer = 0
  9. minetest.register_globalstep(function(dtime)
  10. timer = timer + dtime
  11. if timer >= interval then
  12. timer = 0
  13. local c = #callbacks
  14. for i = 1, c, 1 do
  15. local f = callbacks[i]
  16. f()
  17. end
  18. end
  19. end)