Replace fill globalstep with timer and fix axes
This commit is contained in:
parent
bb03fd547b
commit
a761c9323f
59
map_api.lua
59
map_api.lua
|
@ -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);
|
||||
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();
|
||||
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
|
||||
for _,p in ipairs(minetest.get_connected_players()) do
|
||||
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
|
||||
if stack:get_name() == "cartographer:map" then
|
||||
cartographer.fill_local(stack:get_meta():get_int("cartographer:map_id"), pos.x, pos.z);
|
||||
end
|
||||
for i = -2,2 do
|
||||
for j = -2,2 do
|
||||
local adjusted_pos = {
|
||||
x = pos.x + fromchunk(i),
|
||||
y = pos.y,
|
||||
z = pos.z + fromchunk(j),
|
||||
}
|
||||
cartographer.queue_region(adjusted_pos);
|
||||
end
|
||||
end
|
||||
for i = -2,2 do
|
||||
for j = -2,2 do
|
||||
local adjusted_pos = {
|
||||
x = pos.x + fromchunk(i),
|
||||
y = pos.y,
|
||||
z = pos.z + fromchunk(j),
|
||||
}
|
||||
cartographer.queue_region(adjusted_pos);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1,10 do
|
||||
cartographer.scan_regions();
|
||||
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
|
||||
-- name: A string containing the biome name
|
||||
|
|
Loading…
Reference in New Issue
Block a user