diff --git a/init.lua b/init.lua index 1c3af79..6eb16d3 100644 --- a/init.lua +++ b/init.lua @@ -84,6 +84,8 @@ maps.create_map = function(pos, player_name) { 150, 105, 55 }, -- more liquid { 165, 120, 70 }, -- more liquid { 150, 105, 55 }, -- more liquid + { 60, 35, 16 }, -- tree outline + { 150, 105, 55 }, -- tree fill } for x = 1,size,1 do for z = 1,size,1 do @@ -132,6 +134,80 @@ maps.create_map = function(pos, player_name) end end + local positions = minetest.find_nodes_in_area_under_air( + minp, + maxp, + { + "group:leaves", + "default:snow", -- snow-covered leaves + } + ) + for _, p in ipairs(positions) do + local z = p.z - minp.z + 1 + local x = p.x - minp.x + 1 + local node = minetest.get_node({ + x=p.x, + y=p.y - 4, + z=p.z, + }) + local draw_tree = ( + minetest.get_item_group( + node.name, + "tree" + ) > 0 ) and ( + z < size - 6 and + x > 3 and + x < size - 3 + ) + if draw_tree then + local tree = {} + if nil ~= node.name:find("pine") then + tree = { + " # ", + "#####", + "#...#", + " #.# ", + " #.# ", + " # ", + } + else + tree = { + " # ", + " # ", + " ### ", + "#...#", + "#...#", + "#...#", + " ### ", + } + end + local overlap = false + for t_z = 1,#tree do + for t_x = 1,#tree[t_z] do + local color = pixels[z + t_z][x + t_x - 3][1] + -- do not draw trees close together + if 7 == color then + overlap = true + break + end + end + end + if overlap then + tree = {} + end + for t_z = 1,#tree do + for t_x = 1,#tree[t_z] do + local byte = tree[t_z]:byte(t_x) + if 35 == byte then -- # + pixels[z + t_z][x + t_x - 3] = { 7 } + elseif 46 == byte then -- . + pixels[z + t_z][x + t_x - 3] = { 8 } + end + end + end + end + end + local filepath = textures_dir .. filename tga_encoder.image(pixels):save( filepath,