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)
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,63 +243,48 @@ Everness:add_to_queue_on_generated({
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
if not marker_node then
return
end
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
minetest.remove_node(marker_pos)
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if table.indexof(bioluminescent_tree_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - bioluminescent_tree_size_x,
pos.y - bioluminescent_tree_y_dis,
pos.z - bioluminescent_tree_size_z
),
vector.new(
pos.x + bioluminescent_tree_size_x,
pos.y - bioluminescent_tree_y_dis + coral_bioluminescent_tree_size.y,
pos.z + bioluminescent_tree_size_z
),
{
'air',
'everness:coral_tree'
},
true
)
minetest.remove_node(marker_pos)
local air = positions.air or {}
local tree = positions['everness:coral_tree'] or {}
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
-- do not overlap another tree
if #tree == 0 and #air > bioluminescent_tree_safe_volume then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - bioluminescent_tree_y_dis, marker_pos.z),
schem_bioluminescent_tree,
'random',
nil,
true,
'place_center_x, place_center_z'
)
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - bioluminescent_tree_size_x,
pos.y - bioluminescent_tree_y_dis,
pos.z - bioluminescent_tree_size_z
),
vector.new(
pos.x + bioluminescent_tree_size_x,
pos.y - bioluminescent_tree_y_dis + coral_bioluminescent_tree_size.y,
pos.z + bioluminescent_tree_size_z
),
{
'air',
'everness:coral_tree'
},
true
)
local air = positions.air or {}
local tree = positions['everness:coral_tree'] or {}
if #tree > 1 then
-- will overlap another tree
return
end
if #air > bioluminescent_tree_safe_volume then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - bioluminescent_tree_y_dis, marker_pos.z),
schem_bioluminescent_tree,
'random',
nil,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Coral Tree Bioluminescent was placed at ' .. pos:to_string())
-- minetest.log('action', '[Everness] Coral Tree Bioluminescent was placed at ' .. pos:to_string())
end
end
end
end
end

View File

@ -265,67 +265,58 @@ Everness:add_to_queue_on_generated({
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
if not marker_node then
return
end
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
minetest.remove_node(marker_pos)
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if table.indexof(crystal_cluster_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - crystal_cluster_size_x,
pos.y,
pos.z - crystal_cluster_size_z
),
vector.new(
pos.x + crystal_cluster_size_x,
pos.y + crystal_cluster_size.y,
pos.z + crystal_cluster_size_z
),
{
'air'
},
true
)
minetest.remove_node(marker_pos)
local air = positions.air or {}
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
if #air > crystal_cluster_safe_volume then
local replacements
local rand_color
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - crystal_cluster_size_x,
pos.y,
pos.z - crystal_cluster_size_z
),
vector.new(
pos.x + crystal_cluster_size_x,
pos.y + crystal_cluster_size.y,
pos.z + crystal_cluster_size_z
),
{
'air'
},
true
)
if rand:next(0, 100) < 25 then
local colors = { 'purple', 'cyan' }
rand_color = colors[rand:next(1, #colors)]
local air = positions.air or {}
replacements = {
['everness:crystal_block_orange'] = 'everness:crystal_block_' .. rand_color,
['everness:crystal_orange'] = 'everness:crystal_' .. rand_color
}
end
if #air > crystal_cluster_safe_volume then
local replacements
local rand_color
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y, marker_pos.z),
schem_crystal_cluster,
'random',
replacements,
true,
'place_center_x, place_center_z'
)
if rand:next(0, 100) < 25 then
local colors = { 'purple', 'cyan' }
rand_color = colors[rand:next(1, #colors)]
replacements = {
['everness:crystal_block_orange'] = 'everness:crystal_block_' .. rand_color,
['everness:crystal_orange'] = 'everness:crystal_' .. rand_color
}
-- minetest.log('action', '[Everness] Crystal Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
end
end
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y, marker_pos.z),
schem_crystal_cluster,
'random',
replacements,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Crystal Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
end
end
@ -339,84 +330,75 @@ Everness:add_to_queue_on_generated({
local place_on_node = minetest.get_node(pos)
local crystal_sphere_cluster_y_dis = rand:next(5, 9)
if not marker_node then
return
end
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
minetest.remove_node(marker_pos)
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if table.indexof(crystal_sphere_cluster_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - crystal_sphere_cluster_size_x,
pos.y - crystal_sphere_cluster_y_dis,
pos.z - crystal_sphere_cluster_size_z
),
vector.new(
pos.x + crystal_sphere_cluster_size_x,
pos.y - crystal_sphere_cluster_y_dis + crystal_sphere_cluster_size.y,
pos.z + crystal_sphere_cluster_size_z
),
{
'air',
'everness:coral_tree',
'everness:crystal_block_orange',
'everness:crystal_block_purple',
'everness:crystal_block_cyan',
},
true
)
minetest.remove_node(marker_pos)
local air = positions.air or {}
local tree = positions['everness:coral_tree'] or {}
local block_orange = positions['everness:crystal_block_orange'] or {}
local block_purple = positions['everness:crystal_block_purple'] or {}
local block_cyan = positions['everness:crystal_block_cyan'] or {}
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
if
#air > crystal_sphere_cluster_safe_volume
-- do not overlap
and not (
#tree > 0
or #block_orange > 0
or #block_purple > 0
or #block_cyan > 0
)
then
local replacements
local rand_color
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - crystal_sphere_cluster_size_x,
pos.y - crystal_sphere_cluster_y_dis,
pos.z - crystal_sphere_cluster_size_z
),
vector.new(
pos.x + crystal_sphere_cluster_size_x,
pos.y - crystal_sphere_cluster_y_dis + crystal_sphere_cluster_size.y,
pos.z + crystal_sphere_cluster_size_z
),
{
'air',
'everness:coral_tree',
'everness:crystal_block_orange',
'everness:crystal_block_purple',
'everness:crystal_block_cyan',
},
true
)
if rand:next(0, 100) < 25 then
local colors = { 'orange', 'cyan' }
rand_color = colors[rand:next(1, #colors)]
local air = positions.air or {}
local tree = positions['everness:coral_tree'] or {}
local block_orange = positions['everness:crystal_block_orange'] or {}
local block_purple = positions['everness:crystal_block_purple'] or {}
local block_cyan = positions['everness:crystal_block_cyan'] or {}
replacements = {
['everness:crystal_block_purple'] = 'everness:crystal_block_' .. rand_color,
['everness:crystal_purple'] = 'everness:crystal_' .. rand_color
}
end
if #tree > 0
or #block_orange > 0
or #block_purple > 0
or #block_cyan > 0
then
-- will overlap
return
end
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - crystal_sphere_cluster_y_dis, marker_pos.z),
schem_crystal_sphere_cluster,
'random',
replacements,
true,
'place_center_x, place_center_z'
)
if #air > crystal_sphere_cluster_safe_volume then
local replacements
local rand_color
if rand:next(0, 100) < 25 then
local colors = { 'orange', 'cyan' }
rand_color = colors[rand:next(1, #colors)]
replacements = {
['everness:crystal_block_purple'] = 'everness:crystal_block_' .. rand_color,
['everness:crystal_purple'] = 'everness:crystal_' .. rand_color
}
-- minetest.log('action', '[Everness] Crystal Sphere Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
end
end
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - crystal_sphere_cluster_y_dis, marker_pos.z),
schem_crystal_sphere_cluster,
'random',
replacements,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Crystal Sphere Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
end
end
end

View File

@ -249,63 +249,47 @@ Everness:add_to_queue_on_generated({
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
if not marker_node then
return
end
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
minetest.remove_node(marker_pos)
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if table.indexof(cursed_dream_tree_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - cursed_dream_tree_size_x,
pos.y - cursed_dream_tree_y_dis,
pos.z - cursed_dream_tree_size_z
),
vector.new(
pos.x + cursed_dream_tree_size_x,
pos.y - cursed_dream_tree_y_dis + cursed_dream_tree_size.y,
pos.z + cursed_dream_tree_size_z
),
{
'air',
'everness:dry_tree'
},
true
)
minetest.remove_node(marker_pos)
local air = positions.air or {}
local tree = positions['everness:dry_tree'] or {}
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
if #air > cursed_dream_tree_safe_volume and #tree <= 1 then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - cursed_dream_tree_y_dis, marker_pos.z),
schem_cursed_dream_tree,
'random',
nil,
true,
'place_center_x, place_center_z'
)
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - cursed_dream_tree_size_x,
pos.y - cursed_dream_tree_y_dis,
pos.z - cursed_dream_tree_size_z
),
vector.new(
pos.x + cursed_dream_tree_size_x,
pos.y - cursed_dream_tree_y_dis + cursed_dream_tree_size.y,
pos.z + cursed_dream_tree_size_z
),
{
'air',
'everness:dry_tree'
},
true
)
local air = positions.air or {}
local tree = positions['everness:dry_tree'] or {}
if #tree > 1 then
-- will overlap another tree
return
end
if #air > cursed_dream_tree_safe_volume then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - cursed_dream_tree_y_dis, marker_pos.z),
schem_cursed_dream_tree,
'random',
nil,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Cursed Dream Tree was placed at ' .. pos:to_string())
-- minetest.log('action', '[Everness] Cursed Dream Tree was placed at ' .. pos:to_string())
end
end
end
end
end

View File

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

View File

@ -308,63 +308,47 @@ Everness:add_to_queue_on_generated({
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
if not marker_node then
return
end
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
minetest.remove_node(marker_pos)
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if table.indexof(willow_tree_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - size_x,
pos.y - y_dis,
pos.z - size_z
),
vector.new(
pos.x + size_x,
pos.y - y_dis + size.y,
pos.z + size_z
),
{
'air',
'everness:willow_tree'
},
true
)
minetest.remove_node(marker_pos)
local air = positions.air or {}
local tree = positions['everness:willow_tree'] or {}
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
if #air > safe_volume and #tree == 0 then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - y_dis, marker_pos.z),
willow_tree_schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - size_x,
pos.y - y_dis,
pos.z - size_z
),
vector.new(
pos.x + size_x,
pos.y - y_dis + size.y,
pos.z + size_z
),
{
'air',
'everness:willow_tree'
},
true
)
local air = positions.air or {}
local tree = positions['everness:willow_tree'] or {}
if #tree > 1 then
-- will overlap another tree
return
end
if #air > safe_volume then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - y_dis, marker_pos.z),
willow_tree_schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Willow Tree was placed at ' .. pos:to_string())
-- minetest.log('action', '[Everness] Willow Tree was placed at ' .. pos:to_string())
end
end
end
end
end

View File

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