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,43 +98,40 @@ 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); return math.floor(tochunk(x) / map.scale + 0.5), math.floor(tochunk(z) / map.scale + 0.5);
end end
local timer = 0; -- Periodically-called function to fill in maps and queue chunks for manual
minetest.register_globalstep(function(dt) -- scanning
-- TODO: We need a better way to do this. minetest.after maybe? local function fill_loop()
timer = timer - dt; -- Fill in all player-held maps
if timer < 0 then for _,p in ipairs(minetest.get_connected_players()) do
timer = timer + 5; local inventory = p:get_inventory();
local pos = p:get_pos();
if pos.y > -10 then
for i = 1,inventory:get_size("main") do
local stack = inventory:get_stack("main", i);
-- Fill in all player-held maps if stack:get_name() == "cartographer:map" then
for _,p in ipairs(minetest.get_connected_players()) do cartographer.fill_local(stack:get_meta():get_int("cartographer:map_id"), pos.x, pos.z);
local inventory = p:get_inventory();
local pos = p:get_pos();
if pos.y > -10 then
for i = 1,inventory:get_size("main") do
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);
end
end end
for i = -2,2 do end
for j = -2,2 do for i = -2,2 do
local adjusted_pos = { for j = -2,2 do
x = pos.x + fromchunk(i), local adjusted_pos = {
y = pos.y, x = pos.x + fromchunk(i),
z = pos.z + fromchunk(j), y = pos.y,
} z = pos.z + fromchunk(j),
cartographer.queue_region(adjusted_pos); }
end cartographer.queue_region(adjusted_pos);
end end
end end
end end
for i = 1,10 do
cartographer.scan_regions();
end
end end
end)
for _ = 1,10 do
cartographer.scan_regions();
end
minetest.after(5, fill_loop);
end
minetest.after(5, fill_loop);
-- Register a biome with textures to display -- Register a biome with textures to display
-- name: A string containing the biome name -- name: A string containing the biome name