Mild refactoring

This commit is contained in:
Hugues Ross 2020-04-10 07:14:47 -04:00
parent a45e3ca66a
commit a964f42270

View File

@ -52,42 +52,40 @@ 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 name = minetest.get_biome_name(column[j * map_scale].biome);
local height = column[j * map_scale].height; local height = column[j * map_scale].height;
local biome = cartographer.get_biome_texture(name, math.floor(height + 0.5), detail); local biome = cartographer.get_biome_texture(name, math.floor(height + 0.5), detail);
if biome then
local depth = math.min(math.max(math.floor(height / 8), -8), 0) * -1 local depth = math.min(math.max(math.floor(height / 8), -8), 0) * -1
height = math.max(math.min(math.floor(height / 4), 8), 0) height = math.max(math.min(math.floor(height / 4), 8), 0)
local mod = ""; local mod = "";
if height > 0 then if height > 0 then
mod = "^[colorize:white:"..tostring(height * 10) 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 elseif depth > 0 then
mod = "^[colorize:#1f1f34:"..tostring(depth * 10) mod = "^[colorize:#1f1f34:"..tostring(depth * 10)
end end
if biome == nil then str = str..tile:format(fx, fy - height, scale, scale, biome .. "." .. tostring(get_variant(random)) .. ".png" .. mod)
str = str .. unknown_biome_tile(fx, fy, scale, get_variant(random));
else
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");
end
str = str..tile:format(fx, fy - (height * 0.05), scale, scale, biome .. "." .. tostring(get_variant(random)) .. ".png" .. mod)
end
if get_marker then if get_marker then
local marker = cartographer.get_marker_texture(get_marker(user, i, j), detail); local marker = cartographer.get_marker_texture(get_marker(user, i, j), detail);
if marker then if marker then
str = str..tile:format(fx, fy - (height * 0.05), scale, scale, marker .. ".png") str = str..tile:format(fx, fy - height, scale, scale, marker .. ".png")
end end
end end
if i == player_x and j == player_y then if i == player_x and j == player_y then
str = str..marker:format(fx, fy - (height * 0.05), str = str..marker:format(fx, fy - height,
scale, scale, scale, scale,
cartographer.skin.player_icon.texture .. ".png", cartographer.skin.player_icon.texture .. ".png",
cartographer.skin.player_icon.frame_count, cartographer.skin.player_icon.frame_count,
cartographer.skin.player_icon.frame_duration); cartographer.skin.player_icon.frame_duration);
end end
else
str = str .. unknown_biome_tile(fx, fy, scale, get_variant(random));
end
end end
end end
end end