Replace fill globalstep with timer and fix axes
This commit is contained in:
parent
bb03fd547b
commit
a761c9323f
17
map_api.lua
17
map_api.lua
@ -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);
|
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;
|
|
||||||
if timer < 0 then
|
|
||||||
timer = timer + 5;
|
|
||||||
|
|
||||||
-- Fill in all player-held maps
|
-- Fill in all player-held maps
|
||||||
for _,p in ipairs(minetest.get_connected_players()) do
|
for _,p in ipairs(minetest.get_connected_players()) do
|
||||||
local inventory = p:get_inventory();
|
local inventory = p:get_inventory();
|
||||||
@ -114,7 +110,7 @@ minetest.register_globalstep(function(dt)
|
|||||||
local stack = inventory:get_stack("main", i);
|
local stack = inventory:get_stack("main", i);
|
||||||
|
|
||||||
if stack:get_name() == "cartographer:map" then
|
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
|
||||||
end
|
end
|
||||||
for i = -2,2 do
|
for i = -2,2 do
|
||||||
@ -130,11 +126,12 @@ minetest.register_globalstep(function(dt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1,10 do
|
for _ = 1,10 do
|
||||||
cartographer.scan_regions();
|
cartographer.scan_regions();
|
||||||
end
|
end
|
||||||
|
minetest.after(5, fill_loop);
|
||||||
end
|
end
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user