From a45e3ca66aa6969e1ecdf87968e6a8f7b26bd9ed Mon Sep 17 00:00:00 2001 From: Hugues Ross Date: Fri, 10 Apr 2020 07:00:29 -0400 Subject: [PATCH] Fix missing player marker --- map_formspec.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/map_formspec.lua b/map_formspec.lua index 77b496e..118856f 100644 --- a/map_formspec.lua +++ b/map_formspec.lua @@ -20,9 +20,27 @@ local function unknown_biome_tile(x, y, scale, variant) return tile:format(x, y, scale, scale, cartographer.skin.unknown_biome_texture .. "." .. tostring(variant) .. ".png"); end +-- Generate formspec markup for a given map +-- data: The mapping data +-- x: The X position of the map (in map coordinates) +-- y: The Z position of the map (in map coordinates) +-- w: The width of the map (in map coordinates) +-- h: The height of the map (in map coordinates) +-- player_x: The X position of the player marker (in map coordinates) +-- player_y: The Y position of the player marker (in map coordinates) +-- detail: The detail level +-- map_scale: Integer scaling factor for displaying a zoomed-out map +-- (Optional) is_visible: Callback to determine if a tile should be drawn +-- (Optional) get_marker: Callback to get the marker for any given tile +-- (Optional) user: userdata passed to the is_visible/get_marker callbacks +-- +-- Returns a formspec string local function generate_map(data, x, y, w, h, player_x, player_y, detail, map_scale, is_visible, get_marker, user) local str = ""; local random = PcgRandom(x + y + w + h); -- TODO: Better seed + player_x = math.floor(player_x / map_scale + 0.5); + player_y = math.floor(player_y / map_scale + 0.5); + for i = x,x + w,1 do local fx = (i - x) * (scale - 0.01); local column = data.generated[i * map_scale];