Replace fill globalstep with timer and fix axes

This commit is contained in:
Hugues Ross 2020-06-01 18:10:26 -04:00
parent bb03fd547b
commit a761c9323f

View File

@ -98,13 +98,9 @@ function cartographer.to_map_coordinates(map, x, z)
return math.floor(tochunk(x) / map.scale + 0.5), math.floor(tochunk(z) / map.scale + 0.5);
end
local timer = 0;
minetest.register_globalstep(function(dt)
-- TODO: We need a better way to do this. minetest.after maybe?
timer = timer - dt;
if timer < 0 then
timer = timer + 5;
-- Periodically-called function to fill in maps and queue chunks for manual
-- scanning
local function fill_loop()
-- Fill in all player-held maps
for _,p in ipairs(minetest.get_connected_players()) do
local inventory = p:get_inventory();
@ -114,7 +110,7 @@ minetest.register_globalstep(function(dt)
local stack = inventory:get_stack("main", i);
if stack:get_name() == "cartographer:map" then
cartographer.fill_local(stack:get_meta():get_int("cartographer:map_id"), pos.x, pos.y);
cartographer.fill_local(stack:get_meta():get_int("cartographer:map_id"), pos.x, pos.z);
end
end
for i = -2,2 do
@ -130,11 +126,12 @@ minetest.register_globalstep(function(dt)
end
end
for i = 1,10 do
for _ = 1,10 do
cartographer.scan_regions();
end
minetest.after(5, fill_loop);
end
end)
minetest.after(5, fill_loop);
-- Register a biome with textures to display
-- name: A string containing the biome name