Fix early return causing loop to break, disable falling vines on willow tree

This commit is contained in:
Juraj Vajda 2024-02-14 16:59:01 -05:00
parent 06c72f7fc2
commit 4a66428998
7 changed files with 255 additions and 285 deletions

26
api.lua
View File

@ -2154,3 +2154,29 @@ function Everness.add_to_queue_on_generated(self, def)
table.insert(self.on_generated_queue, def) table.insert(self.on_generated_queue, def)
end end
function Everness.find_irecursive(table, c_id)
local found = false
for i, v in ipairs(table) do
if type(v) == 'table' then
Everness.find_irecursive(v, c_id)
end
if c_id == v then
found = true
break
end
end
return found
end
---Merge two tables with key/value pair
---@param t1 table
---@param t2 table
---@return table
function Everness.mergeTables(t1, t2)
for k, v in pairs(t2) do t1[k] = v end
return t1
end

View File

@ -243,24 +243,11 @@ Everness:add_to_queue_on_generated({
local marker_node = minetest.get_node(marker_pos) local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos) local place_on_node = minetest.get_node(pos)
if not marker_node then if marker_node and marker_node.name == 'everness:marker' then
return -- remove marker
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos) minetest.remove_node(marker_pos)
if table.indexof(bioluminescent_tree_place_on, place_on_node.name) == -1 then if table.indexof(bioluminescent_tree_place_on, place_on_node.name) ~= -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- enough air to place structure ? -- enough air to place structure ?
local positions = minetest.find_nodes_in_area( local positions = minetest.find_nodes_in_area(
vector.new( vector.new(
@ -283,12 +270,8 @@ Everness:add_to_queue_on_generated({
local air = positions.air or {} local air = positions.air or {}
local tree = positions['everness:coral_tree'] or {} local tree = positions['everness:coral_tree'] or {}
if #tree > 1 then -- do not overlap another tree
-- will overlap another tree if #tree == 0 and #air > bioluminescent_tree_safe_volume then
return
end
if #air > bioluminescent_tree_safe_volume then
minetest.place_schematic_on_vmanip( minetest.place_schematic_on_vmanip(
vm, vm,
vector.new(marker_pos.x, marker_pos.y - bioluminescent_tree_y_dis, marker_pos.z), vector.new(marker_pos.x, marker_pos.y - bioluminescent_tree_y_dis, marker_pos.z),
@ -303,4 +286,6 @@ Everness:add_to_queue_on_generated({
end end
end end
end end
end
end
}) })

View File

@ -265,22 +265,11 @@ Everness:add_to_queue_on_generated({
local marker_node = minetest.get_node(marker_pos) local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos) local place_on_node = minetest.get_node(pos)
if not marker_node then if marker_node and marker_node.name == 'everness:marker' then
return -- remove marker
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos) minetest.remove_node(marker_pos)
if table.indexof(crystal_cluster_place_on, place_on_node.name) == -1 then if table.indexof(crystal_cluster_place_on, place_on_node.name) ~= -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- enough air to place structure ? -- enough air to place structure ?
local positions = minetest.find_nodes_in_area( local positions = minetest.find_nodes_in_area(
vector.new( vector.new(
@ -328,6 +317,8 @@ Everness:add_to_queue_on_generated({
-- minetest.log('action', '[Everness] Crystal Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string()) -- minetest.log('action', '[Everness] Crystal Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
end end
end end
end
end
-- --
-- Crystal Sphere Cluster -- Crystal Sphere Cluster
@ -339,22 +330,11 @@ Everness:add_to_queue_on_generated({
local place_on_node = minetest.get_node(pos) local place_on_node = minetest.get_node(pos)
local crystal_sphere_cluster_y_dis = rand:next(5, 9) local crystal_sphere_cluster_y_dis = rand:next(5, 9)
if not marker_node then if marker_node and marker_node.name == 'everness:marker' then
return -- remove marker
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos) minetest.remove_node(marker_pos)
if table.indexof(crystal_sphere_cluster_place_on, place_on_node.name) == -1 then if table.indexof(crystal_sphere_cluster_place_on, place_on_node.name) ~= -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- enough air to place structure ? -- enough air to place structure ?
local positions = minetest.find_nodes_in_area( local positions = minetest.find_nodes_in_area(
vector.new( vector.new(
@ -383,16 +363,16 @@ Everness:add_to_queue_on_generated({
local block_purple = positions['everness:crystal_block_purple'] or {} local block_purple = positions['everness:crystal_block_purple'] or {}
local block_cyan = positions['everness:crystal_block_cyan'] or {} local block_cyan = positions['everness:crystal_block_cyan'] or {}
if #tree > 0 if
#air > crystal_sphere_cluster_safe_volume
-- do not overlap
and not (
#tree > 0
or #block_orange > 0 or #block_orange > 0
or #block_purple > 0 or #block_purple > 0
or #block_cyan > 0 or #block_cyan > 0
)
then then
-- will overlap
return
end
if #air > crystal_sphere_cluster_safe_volume then
local replacements local replacements
local rand_color local rand_color
@ -420,4 +400,6 @@ Everness:add_to_queue_on_generated({
end end
end end
end end
end
end
}) })

View File

@ -249,24 +249,11 @@ Everness:add_to_queue_on_generated({
local marker_node = minetest.get_node(marker_pos) local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos) local place_on_node = minetest.get_node(pos)
if not marker_node then if marker_node and marker_node.name == 'everness:marker' then
return -- remove marker
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos) minetest.remove_node(marker_pos)
if table.indexof(cursed_dream_tree_place_on, place_on_node.name) == -1 then if table.indexof(cursed_dream_tree_place_on, place_on_node.name) ~= -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- enough air to place structure ? -- enough air to place structure ?
local positions = minetest.find_nodes_in_area( local positions = minetest.find_nodes_in_area(
vector.new( vector.new(
@ -289,12 +276,7 @@ Everness:add_to_queue_on_generated({
local air = positions.air or {} local air = positions.air or {}
local tree = positions['everness:dry_tree'] or {} local tree = positions['everness:dry_tree'] or {}
if #tree > 1 then if #air > cursed_dream_tree_safe_volume and #tree <= 1 then
-- will overlap another tree
return
end
if #air > cursed_dream_tree_safe_volume then
minetest.place_schematic_on_vmanip( minetest.place_schematic_on_vmanip(
vm, vm,
vector.new(marker_pos.x, marker_pos.y - cursed_dream_tree_y_dis, marker_pos.z), vector.new(marker_pos.x, marker_pos.y - cursed_dream_tree_y_dis, marker_pos.z),
@ -309,4 +291,6 @@ Everness:add_to_queue_on_generated({
end end
end end
end end
end
end
}) })

View File

@ -67,7 +67,7 @@ Everness:register_ore({
octaves = 1, octaves = 1,
persist = 0.0 persist = 0.0
}, },
biomes = { 'everness_forsaken_tundra_ocean' } biomes = { 'everness:forsaken_tundra_ocean' }
}) })
-- --
@ -87,7 +87,7 @@ Everness:register_decoration({
octaves = 3, octaves = 3,
persist = 0.7, persist = 0.7,
}, },
biomes = { 'everness_forsaken_tundra_ocean' }, biomes = { 'everness:forsaken_tundra_ocean' },
y_max = y_max, y_max = y_max,
y_min = y_min, y_min = y_min,
place_offset_y = -1, place_offset_y = -1,

View File

@ -308,24 +308,11 @@ Everness:add_to_queue_on_generated({
local marker_node = minetest.get_node(marker_pos) local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos) local place_on_node = minetest.get_node(pos)
if not marker_node then if marker_node and marker_node.name == 'everness:marker' then
return -- remove marker
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos) minetest.remove_node(marker_pos)
if table.indexof(willow_tree_place_on, place_on_node.name) == -1 then if table.indexof(willow_tree_place_on, place_on_node.name) ~= -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- enough air to place structure ? -- enough air to place structure ?
local positions = minetest.find_nodes_in_area( local positions = minetest.find_nodes_in_area(
vector.new( vector.new(
@ -348,12 +335,7 @@ Everness:add_to_queue_on_generated({
local air = positions.air or {} local air = positions.air or {}
local tree = positions['everness:willow_tree'] or {} local tree = positions['everness:willow_tree'] or {}
if #tree > 1 then if #air > safe_volume and #tree == 0 then
-- will overlap another tree
return
end
if #air > safe_volume then
minetest.place_schematic_on_vmanip( minetest.place_schematic_on_vmanip(
vm, vm,
vector.new(marker_pos.x, marker_pos.y - y_dis, marker_pos.z), vector.new(marker_pos.x, marker_pos.y - y_dis, marker_pos.z),
@ -368,4 +350,6 @@ Everness:add_to_queue_on_generated({
end end
end end
end end
end
end
}) })

View File

@ -58,6 +58,11 @@ local function register_vine(name, def, overrides)
-- ALL -- ALL
flammable = 2, flammable = 2,
} }
if _overrides.groups then
Everness.mergeTables(_def.groups, _overrides.groups)
end
-- MCL -- MCL
_def._mcl_shears_drop = true _def._mcl_shears_drop = true
_def._mcl_blast_resistance = 0.2 _def._mcl_blast_resistance = 0.2
@ -66,7 +71,7 @@ local function register_vine(name, def, overrides)
return false return false
end end
_def.sounds = Everness.node_sound_leaves_defaults() _def.sounds = Everness.node_sound_leaves_defaults()
_def.waving = 2 _def.waving = 1
_def.on_destruct = function(pos) _def.on_destruct = function(pos)
local pos_below = vector.new(pos.x, pos.y - 1, pos.z) local pos_below = vector.new(pos.x, pos.y - 1, pos.z)
local node_below = minetest.get_node(pos_below) local node_below = minetest.get_node(pos_below)
@ -183,6 +188,10 @@ register_vine('bulb_vine', {
register_vine('willow_vine', { register_vine('willow_vine', {
description = S('Willow Vine') description = S('Willow Vine')
}, {
groups = {
falling_vines = 0
}
}) })
-- Eye Vine -- Eye Vine