Finish decorations
							parent
							
								
									18fecc7eae
								
							
						
					
					
						commit
						b1dbac00d3
					
				
							
								
								
									
										201
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										201
									
								
								init.lua
								
								
								
								
							|  | @ -321,7 +321,7 @@ function internal.clean_deco_def(def) | ||||||
|     place("height", "number", 1) |     place("height", "number", 1) | ||||||
|     place("place_offset_y", "number", 0) |     place("place_offset_y", "number", 0) | ||||||
|     place("replacements", "table", {}) |     place("replacements", "table", {}) | ||||||
|     place("flags", "string", "") |     place("flags", "string", "place_center_x,place_center_z") | ||||||
|     place("rotation", "string", "0") |     place("rotation", "string", "0") | ||||||
| 
 | 
 | ||||||
|     d.height     = math.max(d.height    ,  0) |     d.height     = math.max(d.height    ,  0) | ||||||
|  | @ -575,6 +575,11 @@ function internal.flat_from_node_types(bools, minp, maxp) | ||||||
|                 return nt.floor_deco |                 return nt.floor_deco | ||||||
|             end |             end | ||||||
| 
 | 
 | ||||||
|  |             if bools:get_index(i + bools.up) == false then | ||||||
|  |                 -- Block is near the ceiling | ||||||
|  |                 return nt.ceiling_deco | ||||||
|  |             end | ||||||
|  | 
 | ||||||
|             return nt.air |             return nt.air | ||||||
|         else |         else | ||||||
|             -- NOT PART OF CAVE |             -- NOT PART OF CAVE | ||||||
|  | @ -745,8 +750,12 @@ function internal.generate_caves(data, minp, maxp) | ||||||
|                 place(def.node_wall) |                 place(def.node_wall) | ||||||
|             elseif nt == internal.node_types.ceiling then |             elseif nt == internal.node_types.ceiling then | ||||||
|                 place(def.node_roof) |                 place(def.node_roof) | ||||||
|             elseif nt == internal.node_types.floor_deco then |             elseif nt == internal.node_types.floor_deco or nt == internal.node_types.ceiling_deco then | ||||||
|                 local schem_placed = false |                 local schem_placed = false | ||||||
|  |                 local appropriate_place = "floor" | ||||||
|  |                 if nt == internal.node_types.ceiling_deco then | ||||||
|  |                     appropriate_place = "ceiling" | ||||||
|  |                 end | ||||||
| 
 | 
 | ||||||
|                 if not schem_placed then |                 if not schem_placed then | ||||||
|                     -- Prevent decorations from spawning in the air |                     -- Prevent decorations from spawning in the air | ||||||
|  | @ -757,7 +766,7 @@ function internal.generate_caves(data, minp, maxp) | ||||||
| 
 | 
 | ||||||
|                 if not schem_placed then |                 if not schem_placed then | ||||||
|                     for _, deco in ipairs(noordstar_caves.registered_decorations) do |                     for _, deco in ipairs(noordstar_caves.registered_decorations) do | ||||||
|                         if deco.place_on ~= "floor" then |                         if deco.place_on ~= appropriate_place then | ||||||
|                         elseif math.random() > deco.fill_ratio then |                         elseif math.random() > deco.fill_ratio then | ||||||
|                         elseif not internal.is_deco_biome(deco, def.name) then |                         elseif not internal.is_deco_biome(deco, def.name) then | ||||||
|                         else |                         else | ||||||
|  | @ -769,7 +778,12 @@ function internal.generate_caves(data, minp, maxp) | ||||||
|                 end |                 end | ||||||
| 
 | 
 | ||||||
|                 if not schem_placed then |                 if not schem_placed then | ||||||
|                     place(def.node_dust or "air") |                     local n = "air" | ||||||
|  |                     if nt == internal.node_types.floor_deco then | ||||||
|  |                         n = def.node_dust or n | ||||||
|  |                     end | ||||||
|  |                     place(n) | ||||||
|  |                     schem_placed = true | ||||||
|                 end |                 end | ||||||
|             else |             else | ||||||
|                 error( |                 error( | ||||||
|  | @ -913,16 +927,42 @@ end | ||||||
| -- Place all schematic decorations into the world | -- Place all schematic decorations into the world | ||||||
| function internal.place_schematic_decorations(vmanip, schems) | function internal.place_schematic_decorations(vmanip, schems) | ||||||
|     for _, schem in ipairs(schems) do |     for _, schem in ipairs(schems) do | ||||||
|         local pos  = schem.pos |         local pos  = { | ||||||
|  |             x = schem.pos.x, | ||||||
|  |             y = schem.pos.y + schem.deco.place_offset_y, | ||||||
|  |             z = schem.pos.z, | ||||||
|  |         } | ||||||
|         local deco = schem.deco |         local deco = schem.deco | ||||||
| 
 | 
 | ||||||
|         if deco.deco_type ~= "schematic" then |         if deco.deco_type ~= "schematic" then | ||||||
|         else |         else | ||||||
|             minetest.place_schematic_on_vmanip( |             if deco.place_on == "floor" then | ||||||
|                 vmanip, pos, |                 minetest.place_schematic_on_vmanip( | ||||||
|                 deco.schematic, deco.rotation, deco.replacement, |                     vmanip, pos, | ||||||
|                 true, deco.flags |                     deco.schematic, deco.rotation, deco.replacement, | ||||||
|             ) |                     true, deco.flags | ||||||
|  |                 ) | ||||||
|  |             elseif deco.place_on == "ceiling" then | ||||||
|  |                 local h = deco.schematic | ||||||
|  | 
 | ||||||
|  |                 if type(deco.schematic) == "string" then | ||||||
|  |                     h = minetest.read_schematic(h, {}) | ||||||
|  | 
 | ||||||
|  |                     if type(h) == "nil" then | ||||||
|  |                         error("Could not find schematic! Perhaps it the filename is incorrect?") | ||||||
|  |                     end | ||||||
|  |                 end | ||||||
|  | 
 | ||||||
|  |                 h = h.size.y | ||||||
|  | 
 | ||||||
|  |                 minetest.place_schematic_on_vmanip( | ||||||
|  |                     vmanip, { x = pos.x, y = pos.y - h + 1, z = pos.z }, | ||||||
|  |                     deco.schematic, deco.rotation, deco.replacement, | ||||||
|  |                     true, deco.flags | ||||||
|  |                 ) | ||||||
|  |             else | ||||||
|  |                 error("Unknown place_on value `" .. deco.place_on .. "`") | ||||||
|  |             end | ||||||
|         end |         end | ||||||
|     end |     end | ||||||
| end | end | ||||||
|  | @ -931,7 +971,11 @@ end | ||||||
| function internal.place_simple_decorations(flat, schems) | function internal.place_simple_decorations(flat, schems) | ||||||
|     for _, schem in ipairs(schems) do |     for _, schem in ipairs(schems) do | ||||||
|         if schem.deco.deco_type == "simple" then |         if schem.deco.deco_type == "simple" then | ||||||
|             local pos  = schem.pos |             local pos  = { | ||||||
|  |                 x = schem.pos.x, | ||||||
|  |                 y = schem.pos.y + schem.deco.place_offset_y, | ||||||
|  |                 z = schem.pos.z, | ||||||
|  |             } | ||||||
|             local deco = schem.deco |             local deco = schem.deco | ||||||
|              |              | ||||||
|             local i = flat:pos_to_index(pos) |             local i = flat:pos_to_index(pos) | ||||||
|  | @ -1243,84 +1287,104 @@ noordstar_caves.register_shape({ | ||||||
|     connectivity_point = 10, |     connectivity_point = 10, | ||||||
|     verticality_point = 40, |     verticality_point = 40, | ||||||
| }) | }) | ||||||
| -- noordstar_caves.register_shape({ | noordstar_caves.register_shape({ | ||||||
| --     name = "noordstar_caves:cliffs", |     name = "noordstar_caves:cliffs", | ||||||
|      |      | ||||||
| --     noise_params = { |     noise_params = { | ||||||
| --         offset = 0.4, |         offset = 0.4, | ||||||
| --         scale = 0.5, |         scale = 0.5, | ||||||
| --         spread = { x = 20, y = 100, z = 20 }, |         spread = { x = 20, y = 100, z = 20 }, | ||||||
| --         seed = 97354, |         seed = 97354, | ||||||
| --         octaves = 4, |         octaves = 4, | ||||||
| --         persistence = 0.6, |         persistence = 0.6, | ||||||
| --         lacunarity = 2.0, |         lacunarity = 2.0, | ||||||
| --         flags = "" |         flags = "" | ||||||
| --     }, |     }, | ||||||
| 
 | 
 | ||||||
| --     func = function(pos, n) |     func = function(pos, n) | ||||||
| --         return n |         return n | ||||||
| --     end, |     end, | ||||||
| 
 | 
 | ||||||
| --     connectivity_point = 30, |     connectivity_point = 30, | ||||||
| --     verticality_point = 80, |     verticality_point = 80, | ||||||
| -- }) | }) | ||||||
| -- noordstar_caves.register_shape({ | noordstar_caves.register_shape({ | ||||||
| --     name = "noordstar_caves:donuts", |     name = "noordstar_caves:donuts", | ||||||
|      |      | ||||||
| --     noise_params = { |     noise_params = { | ||||||
| --         offset = 0.0, |         offset = 0.0, | ||||||
| --         scale = 1.0, |         scale = 1.0, | ||||||
| --         spread = { x = 30, y = 30, z = 30 }, |         spread = { x = 30, y = 30, z = 30 }, | ||||||
| --         seed = 3934, |         seed = 3934, | ||||||
| --         octaves = 1, |         octaves = 1, | ||||||
| --         persistence = 0.6, |         persistence = 0.6, | ||||||
| --         lacunarity = 2.0, |         lacunarity = 2.0, | ||||||
| --         flags = "eased" |         flags = "eased" | ||||||
| --     }, |     }, | ||||||
| 
 | 
 | ||||||
| --     func = function(pos, n) |     func = function(pos, n) | ||||||
| --         return 1 - 2 * math.abs(n)^0.5 |         return 1 - 2 * math.abs(n)^0.5 | ||||||
| --     end, |     end, | ||||||
| 
 | 
 | ||||||
| --     connectivity_point = 50, |     connectivity_point = 50, | ||||||
| --     verticality_point = 40, |     verticality_point = 40, | ||||||
| -- }) | }) | ||||||
| -- noordstar_caves.register_shape({ | noordstar_caves.register_shape({ | ||||||
| --     name = "noordstar_caves:wall", |     name = "noordstar_caves:wall", | ||||||
| 
 | 
 | ||||||
| --     func = function(pos, n) |     func = function(pos, n) | ||||||
| --         return -0.5 |         return -0.5 | ||||||
| --     end, |     end, | ||||||
| 
 | 
 | ||||||
| --     connectivity_point = 0, |     connectivity_point = 0, | ||||||
| --     verticality_point = 0, |     verticality_point = 0, | ||||||
| -- }) | }) | ||||||
| 
 | 
 | ||||||
| -- noordstar_caves.set_world_depth(-60) | -- noordstar_caves.set_world_depth(-60) | ||||||
| -- noordstar_caves.cave_vastness = function(pos) return math.abs(pos.y - 60) / 120 end | -- noordstar_caves.cave_vastness = function(pos) return math.abs(pos.y - 60) / 120 end | ||||||
| 
 | 
 | ||||||
| noordstar_caves.register_biome({ | noordstar_caves.register_biome({ | ||||||
|     name = "test", |     name = "nc:glowing_floor", | ||||||
|     node_floor = "mcl_core:crying_obsidian", |     node_floor = "mcl_core:crying_obsidian", | ||||||
|     node_wall = "mcl_core:sand", |     node_wall = "mcl_core:sand", | ||||||
|     node_roof = "mcl_ocean:sea_lantern", |     node_roof = "mcl_ocean:sea_lantern", | ||||||
|     node_dust = "mcl_core:snow", |     node_dust = "mcl_core:snow", | ||||||
|     heat_point = 80, |     heat_point = 20, | ||||||
|     humidity_point = 80, |     humidity_point = 0, | ||||||
| }) | }) | ||||||
| noordstar_caves.register_biome({ | noordstar_caves.register_biome({ | ||||||
|     name = "test2", |     name = "nc:crazy_glowin_walls", | ||||||
|     node_floor = "mcl_amethyst:amethyst_block", |     node_floor = "mcl_amethyst:amethyst_block", | ||||||
|     node_wall = "mcl_crimson:shroomlight", |     node_wall = "mcl_crimson:shroomlight", | ||||||
|     node_roof = "mcl_colorblocks:glazed_terracotta_silver", |     node_roof = "mcl_colorblocks:glazed_terracotta_silver", | ||||||
|     heat_point = 100, |     heat_point = 100, | ||||||
|  |     humidity_point = 0, | ||||||
|  | }) | ||||||
|  | noordstar_caves.register_biome({ | ||||||
|  |     name = "nc:regular", | ||||||
|  |     heat_point = 50, | ||||||
|  |     humidity_point = 50, | ||||||
|  | }) | ||||||
|  | noordstar_caves.register_biome({ | ||||||
|  |     name = "nc:cold", | ||||||
|  |     node_dust = "mcl_core:snow", | ||||||
|  |     node_roof = "mcl_core:ice", | ||||||
|  |     heat_point = 10, | ||||||
|  |     humidity_point = 100, | ||||||
|  | }) | ||||||
|  | noordstar_caves.register_biome({ | ||||||
|  |     name = "nc:grass", | ||||||
|  |     node_floor = "mcl_core:dirt_with_grass", | ||||||
|  |     heat_point = 50, | ||||||
|  |     humidity_point = 70, | ||||||
|  | }) | ||||||
|  | noordstar_caves.register_biome({ | ||||||
|  |     name = "nc:dangerous_lava", | ||||||
|  |     node_floor = "mcl_core:lava_source", | ||||||
|  |     y_max = -40, | ||||||
|  |     heat_point = 100, | ||||||
|     humidity_point = 100, |     humidity_point = 100, | ||||||
| }) | }) | ||||||
| -- noordstar_caves.register_biome({ |  | ||||||
| --     name = "test3", |  | ||||||
| --     heat_point = 50, |  | ||||||
| --     humidity_point = 50, |  | ||||||
| -- }) |  | ||||||
| 
 | 
 | ||||||
| noordstar_caves.register_decoration({ | noordstar_caves.register_decoration({ | ||||||
|     deco_type = "simple", |     deco_type = "simple", | ||||||
|  | @ -1329,21 +1393,22 @@ noordstar_caves.register_decoration({ | ||||||
|     decoration = "mcl_core:cactus", |     decoration = "mcl_core:cactus", | ||||||
|     height = 3, |     height = 3, | ||||||
|     height_max = 8, |     height_max = 8, | ||||||
|     biomes = { "test" }, |     biomes = { "nc:glowing_floor" }, | ||||||
| }) | }) | ||||||
| noordstar_caves.register_decoration({ | noordstar_caves.register_decoration({ | ||||||
|     deco_type = "simple", |     deco_type = "simple", | ||||||
|     place_on = "floor", |     place_on = "ceiling", | ||||||
|     fill_ratio = 0.1, |     fill_ratio = 0.1, | ||||||
|     decoration = "mcl_ocean:sea_lantern", |     decoration = "mcl_ocean:sea_lantern", | ||||||
|     height = 1, |     height = 1, | ||||||
|     height_max = 4, |     height_max = 4, | ||||||
|     biomes = { "test2" }, |     biomes = { "nc:crazy_glowin_walls" }, | ||||||
|  |     place_offset_y = -3, | ||||||
| }) | }) | ||||||
| noordstar_caves.register_decoration({ | noordstar_caves.register_decoration({ | ||||||
|     deco_type = "schematic", |     deco_type = "schematic", | ||||||
|     place_on = "floor", |     place_on = "floor", | ||||||
|     fill_ratio = 0.005, |     fill_ratio = 0.001, | ||||||
|     schematic = squeak, |     schematic = squeak, | ||||||
|     rotation = "random", |     rotation = "random", | ||||||
|     -- place_offset_y = 5, |     -- place_offset_y = 5, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue