1
0
mirror of https://github.com/mt-mods/moretrees.git synced 2025-06-30 15:10:51 +02:00

Divorce biome lib and cleanup code (#11)

* make it boot without biome lib

* make luacheck semi sane

* make fast growth saplings work

* make fast saplings respect nodes there growing on

* make regualr saplings work

* fix some luacheck warnings

* add github actions for luacheck

* bump luacheck line limit, as to gracefully handle long tree rules

* switch over to inline luacheck length rules

* fix screenshot warning

* make tree generation work

* add settings from last night

* comment out new biome lib nonsense added

* tune spawning to be better

* turn down fallback ratio

* translate new abm patch to not use biome lib

* add ethereal since its still behaving badly :(
This commit is contained in:
wsor4035
2022-10-24 19:09:19 -04:00
committed by GitHub
parent 8103aaae79
commit e476b81cf5
12 changed files with 328 additions and 118 deletions

View File

@ -52,7 +52,7 @@ ftrunk.after_destruct = function(pos, oldnode)
for _,datespos in pairs(dates) do
-- minetest.dig_node(datespos) does not cause nearby dates to be dropped :-( ...
local items = minetest.get_node_drops(minetest.get_node(datespos).name)
minetest.swap_node(datespos, biome_lib.air)
minetest.swap_node(datespos, {name = "air"})
for _, itemname in pairs(items) do
minetest.add_item(datespos, itemname)
end
@ -83,7 +83,10 @@ local date_regrow_abm_spec = {
interval = moretrees.dates_flower_interval,
chance = moretrees.dates_flower_chance,
action = function(pos, node, active_object_count, active_object_count_wider)
local dates = minetest.find_nodes_in_area({x=pos.x-2, y=pos.y, z=pos.z-2}, {x=pos.x+2, y=pos.y, z=pos.z+2}, "group:moretrees_dates")
local dates = minetest.find_nodes_in_area(
{x=pos.x-2, y=pos.y, z=pos.z-2}, {x=pos.x+2, y=pos.y, z=pos.z+2},
"group:moretrees_dates"
)
-- New blossom interval increases exponentially with number of dates already hanging
-- In addition: if more dates are hanging, the chance of picking an empty spot decreases as well...
@ -228,7 +231,8 @@ local function find_fruit_trunks_near(ftpos, sect)
-- Skip the search if it is consuming too much CPU time
if sect_search_stats.count > 0 and moretrees.dates_blossom_search_iload > 0
and sect_search_stats.sum / sect_search_stats.count > moretrees.dates_blossom_search_time_treshold
and t0us - sect_search_stats.last_us < moretrees.dates_blossom_search_iload * (sect_search_stats.sum / sect_search_stats.count) then
and t0us - sect_search_stats.last_us < moretrees.dates_blossom_search_iload
* (sect_search_stats.sum / sect_search_stats.count) then
sect_search_stats.skip = sect_search_stats.skip + 1
return nil
end
@ -481,7 +485,10 @@ local function find_male_blossom_with_ftrunk(fbpos,ftpos)
end
-- Else do a new search
if not mpalms.sect[sect_old] then
mpalms.sect[sect_old], fpalms_list, all_mpalms_list = find_fruit_trunks_near(ftpos, {x = (sect_old + 4) % 3 - 1, z = (sect_old + 4) / 3 - 1})
mpalms.sect[sect_old], fpalms_list, all_mpalms_list = find_fruit_trunks_near(
ftpos,
{x = (sect_old + 4) % 3 - 1, z = (sect_old + 4) / 3 - 1}
)
cache_changed = true
if sect_old == 0 then
-- Save the results if it is sector 0
@ -547,7 +554,7 @@ local dates_growfn = function(pos, elapsed)
elseif string.find(node.name, "moretrees:dates_m") then
minetest.swap_node(pos, {name="moretrees:dates_n"})
else
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
end
return
elseif node.name == "moretrees:dates_f0" and math.random(100) <= 100 * dates_regrow_prob then
@ -587,7 +594,7 @@ local dates_growfn = function(pos, elapsed)
elseif string.match(node.name, "n$") then
-- Remove stems.
if math.random(stems_drop_ichance) == 1 then
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
return "stemdrop"
end
action = "nostemdrop"