Make fill_local a function of map objects
This commit is contained in:
parent
d7f7210a2d
commit
30249edf44
@ -116,14 +116,18 @@ end
|
||||
-- height_mode: Whether or not to display the map in height mode
|
||||
-- (Optional) marker_page: The current page that the marker editor is on
|
||||
local function show_map_id_formspec(id, player_x, player_z, player_name, height_mode, marker_page)
|
||||
cartographer.fill_local(id, player_x, player_z);
|
||||
local map = cartographer.get_map(id);
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
|
||||
map:fill_local(id, player_x, player_z);
|
||||
|
||||
player_maps[player_name] = {
|
||||
id = id,
|
||||
page = marker_page or 1,
|
||||
height_mode = height_mode,
|
||||
};
|
||||
local map = cartographer.get_map(id);
|
||||
|
||||
player_x, player_z = map:to_coordinates(player_x, player_z)
|
||||
local formspec, formspec_width, _ = map_formspec.from_map(map, player_x, player_z, height_mode);
|
||||
|
19
map_api.lua
19
map_api.lua
@ -79,18 +79,12 @@ end
|
||||
-- id: A map ID
|
||||
-- x: The x position, in world coordinates
|
||||
-- z: The z position, in world coordinates
|
||||
function cartographer.fill_local(id, x, z)
|
||||
local map = cartographer.get_map(id);
|
||||
|
||||
if not map then
|
||||
return;
|
||||
end
|
||||
|
||||
x, z = map:to_coordinates(x, z);
|
||||
function Map.fill_local(self, x, z)
|
||||
x, z = self:to_coordinates(x, z);
|
||||
|
||||
-- TODO: Adjust size to match map scale
|
||||
if x >= map.x - 2 and x <= map.x + map.w + 1 and z >= map.z - 2 and z <= map.z + map.h + 1 then
|
||||
map:fill_area(x - 2, z - 2, 5, 5);
|
||||
if x >= self.x - 2 and x <= self.x + self.w + 1 and z >= self.z - 2 and z <= self.z + self.h + 1 then
|
||||
self:fill_area(x - 2, z - 2, 5, 5);
|
||||
end
|
||||
end
|
||||
|
||||
@ -118,9 +112,10 @@ local function fill_loop()
|
||||
if pos.y > -10 then
|
||||
for i = 1,inventory:get_size("main") do
|
||||
local stack = inventory:get_stack("main", i);
|
||||
local map = cartographer.get_map(stack:get_meta():get_int("cartographer:map_id"));
|
||||
|
||||
if stack:get_name() == "cartographer:map" then
|
||||
cartographer.fill_local(stack:get_meta():get_int("cartographer:map_id"), pos.x, pos.z);
|
||||
if map then
|
||||
map:fill_local(pos.x, pos.z);
|
||||
end
|
||||
end
|
||||
for i = -2,2 do
|
||||
|
Loading…
Reference in New Issue
Block a user