From a964f42270258329bbab080b9e30a5464a5dde1b Mon Sep 17 00:00:00 2001 From: Hugues Ross Date: Fri, 10 Apr 2020 07:14:47 -0400 Subject: [PATCH] Mild refactoring --- map_formspec.lua | 52 +++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/map_formspec.lua b/map_formspec.lua index 118856f..e5bdd57 100644 --- a/map_formspec.lua +++ b/map_formspec.lua @@ -52,41 +52,39 @@ local function generate_map(data, x, y, w, h, player_x, player_y, detail, map_sc local name = minetest.get_biome_name(column[j * map_scale].biome); local height = column[j * map_scale].height; local biome = cartographer.get_biome_texture(name, math.floor(height + 0.5), detail); - local depth = math.min(math.max(math.floor(height / 8), -8), 0) * -1 - height = math.max(math.min(math.floor(height / 4), 8), 0) - local mod = ""; - if height > 0 then - mod = "^[colorize:white:"..tostring(height * 10) - elseif depth > 0 then - mod = "^[colorize:#1f1f34:"..tostring(depth * 10) - end + if biome then + local depth = math.min(math.max(math.floor(height / 8), -8), 0) * -1 + height = math.max(math.min(math.floor(height / 4), 8), 0) - if biome == nil then - str = str .. unknown_biome_tile(fx, fy, scale, get_variant(random)); - else + local mod = ""; if height > 0 then - str = str..tile:format(fx, fy - (height * 0.05) + scale - 0.01, - scale, (height * 0.05) + 0.01, - cartographer.skin.cliff_texture .. ".png"); + mod = "^[colorize:white:"..tostring(height * 10) + height = height * 0.05; + + str = str..tile:format(fx, fy - height + (scale - 0.01), scale, height + 0.01, cartographer.skin.cliff_texture .. ".png"); + elseif depth > 0 then + mod = "^[colorize:#1f1f34:"..tostring(depth * 10) end - str = str..tile:format(fx, fy - (height * 0.05), scale, scale, biome .. "." .. tostring(get_variant(random)) .. ".png" .. mod) - end + str = str..tile:format(fx, fy - height, scale, scale, biome .. "." .. tostring(get_variant(random)) .. ".png" .. mod) - if get_marker then - local marker = cartographer.get_marker_texture(get_marker(user, i, j), detail); - if marker then - str = str..tile:format(fx, fy - (height * 0.05), scale, scale, marker .. ".png") + if get_marker then + local marker = cartographer.get_marker_texture(get_marker(user, i, j), detail); + if marker then + str = str..tile:format(fx, fy - height, scale, scale, marker .. ".png") + end end - end - if i == player_x and j == player_y then - str = str..marker:format(fx, fy - (height * 0.05), - scale, scale, - cartographer.skin.player_icon.texture .. ".png", - cartographer.skin.player_icon.frame_count, - cartographer.skin.player_icon.frame_duration); + if i == player_x and j == player_y then + str = str..marker:format(fx, fy - height, + scale, scale, + cartographer.skin.player_icon.texture .. ".png", + cartographer.skin.player_icon.frame_count, + cartographer.skin.player_icon.frame_duration); + end + else + str = str .. unknown_biome_tile(fx, fy, scale, get_variant(random)); end end end