A minetest mod for mapmaking
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.4KB

  1. -- Arguments
  2. -- chunk: The chunk coordinate conversion API
  3. -- scanner: The map scanning API
  4. -- maps: The map API
  5. -- settings: The mod settings
  6. local chunk, scanner, maps, settings = ...;
  7. -- Periodically-called function to fill in maps and queue chunks for backup
  8. -- scans
  9. if settings.autofill_freq ~= 0 then
  10. -- scanning
  11. local function fill_loop()
  12. -- Fill in all player-held maps
  13. for _,p in ipairs(minetest.get_connected_players()) do
  14. local inventory = p:get_inventory();
  15. local pos = p:get_pos();
  16. if pos.y > -10 then
  17. for i = 1,inventory:get_size("main") do
  18. local stack = inventory:get_stack("main", i);
  19. local map = maps.get(stack:get_meta():get_int("cartographer:map_id"));
  20. if map then
  21. map:fill_local(pos.x, pos.z);
  22. end
  23. end
  24. for i = -4,4 do
  25. for j = -4,4 do
  26. local adjusted_pos = {
  27. x = pos.x + chunk.from(i),
  28. y = pos.y,
  29. z = pos.z + chunk.from(j),
  30. }
  31. scanner.queue_region(adjusted_pos);
  32. end
  33. end
  34. end
  35. end
  36. minetest.after(settings.autofill_freq, fill_loop);
  37. end
  38. minetest.after(settings.autofill_freq, fill_loop);
  39. end