mirror of
https://github.com/mt-mods/moretrees.git
synced 2024-12-25 02:00:23 +01: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:
parent
8103aaae79
commit
e476b81cf5
18
.github/workflows/luacheck.yml
vendored
Normal file
18
.github/workflows/luacheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
name: luacheck
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: apt
|
||||
run: sudo apt-get install -y luarocks
|
||||
- name: luacheck install
|
||||
run: luarocks install --local luacheck
|
||||
- name: luacheck run
|
||||
run: $HOME/.luarocks/bin/luacheck ./
|
35
.luacheckrc
35
.luacheckrc
@ -1,28 +1,25 @@
|
||||
std = "lua51+minetest"
|
||||
unused_args = false
|
||||
allow_defined_top = true
|
||||
max_line_length = 999
|
||||
max_comment_line_length = 999
|
||||
|
||||
stds.minetest = {
|
||||
read_globals = {
|
||||
"minetest",
|
||||
"vector",
|
||||
"VoxelManip",
|
||||
"VoxelArea",
|
||||
"PseudoRandom",
|
||||
"ItemStack",
|
||||
"default",
|
||||
table = {
|
||||
fields = {
|
||||
"copy",
|
||||
},
|
||||
},
|
||||
"dump",
|
||||
}
|
||||
exclude_files = {".luacheckrc"}
|
||||
|
||||
|
||||
globals = {
|
||||
"minetest",
|
||||
"vector",
|
||||
"VoxelManip",
|
||||
"VoxelArea",
|
||||
"PseudoRandom",
|
||||
"ItemStack",
|
||||
"default",
|
||||
"dump",
|
||||
"moretrees",
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
string = {fields = {"split"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
|
||||
"biome_lib",
|
||||
"stairsplus",
|
||||
"stairs",
|
||||
|
@ -69,6 +69,9 @@ moretrees.apple_tree_biome = {
|
||||
temp_max = -0.15,
|
||||
rarity = 75,
|
||||
max_count = 5,
|
||||
place_on = {"default:dirt_with_grass"},
|
||||
biomes = {"deciduous_forest"},
|
||||
fill_ratio = 0.0001,
|
||||
}
|
||||
|
||||
moretrees.oak_biome = {
|
||||
@ -82,6 +85,7 @@ moretrees.oak_biome = {
|
||||
temp_max = 0.2,
|
||||
rarity = 50,
|
||||
max_count = 5,
|
||||
fill_ratio = 0.0003
|
||||
}
|
||||
|
||||
moretrees.sequoia_biome = {
|
||||
@ -95,6 +99,7 @@ moretrees.sequoia_biome = {
|
||||
temp_max = -0.4,
|
||||
rarity = 90,
|
||||
max_count = 5,
|
||||
fill_ratio = 0.0001,
|
||||
}
|
||||
|
||||
moretrees.birch_biome = {
|
||||
@ -108,6 +113,7 @@ moretrees.birch_biome = {
|
||||
temp_max = 0.3,
|
||||
rarity = 50,
|
||||
max_count = 10,
|
||||
fill_ratio = 0.001,
|
||||
}
|
||||
|
||||
moretrees.willow_biome = {
|
||||
@ -145,7 +151,8 @@ moretrees.jungletree_biome = {
|
||||
"default:dirt_with_grass",
|
||||
"woodsoils:dirt_with_leaves_1",
|
||||
"woodsoils:grass_with_leaves_1",
|
||||
"woodsoils:grass_with_leaves_2"
|
||||
"woodsoils:grass_with_leaves_2",
|
||||
"default:dirt_with_rainforest_litter",
|
||||
},
|
||||
avoid_nodes = {"moretrees:jungletree_trunk"},
|
||||
max_count = 12,
|
||||
@ -158,6 +165,7 @@ moretrees.jungletree_biome = {
|
||||
near_nodes_vertical = 2,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
biomes = {"rainforest", "rainforest_swamp"},
|
||||
}
|
||||
|
||||
moretrees.spruce_biome = {
|
||||
|
@ -32,7 +32,7 @@ ftrunk.after_destruct = function(pos, oldnode)
|
||||
-- minetest.dig_node(coconutpos) does not cause nearby coconuts to be dropped :-( ...
|
||||
--minetest.dig_node(coconutpos)
|
||||
local items = minetest.get_node_drops(minetest.get_node(coconutpos).name)
|
||||
minetest.swap_node(coconutpos, biome_lib.air)
|
||||
minetest.swap_node(coconutpos, {name = "air"})
|
||||
for _, itemname in pairs(items) do
|
||||
minetest.add_item(coconutpos, itemname)
|
||||
end
|
||||
@ -82,8 +82,8 @@ minetest.register_abm({
|
||||
nodenames = { "moretrees:palm_fruit_trunk_gen" },
|
||||
interval = 6,
|
||||
chance = 1,
|
||||
min_y = biome_lib.mapgen_elevation_limit.min,
|
||||
max_y = biome_lib.mapgen_elevation_limit.max,
|
||||
min_y = -16,
|
||||
max_y = 48,
|
||||
label = "converts palm trunk to a regular fruit trunk, and spawns some coconuts",
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
minetest.swap_node(pos, {name="moretrees:palm_fruit_trunk"})
|
||||
@ -130,7 +130,7 @@ local coconut_growfn = function(pos, elapsed)
|
||||
minetest.add_item(pos, itemname)
|
||||
end
|
||||
end
|
||||
minetest.swap_node(pos, biome_lib.air)
|
||||
minetest.swap_node(pos, {name = "air"})
|
||||
end
|
||||
else
|
||||
-- Grow coconuts to the next stage
|
||||
|
@ -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"
|
||||
|
172
init.lua
172
init.lua
@ -55,7 +55,7 @@ end
|
||||
local worldpath=minetest.get_worldpath()
|
||||
local modpath=minetest.get_modpath("moretrees")
|
||||
|
||||
dofile(modpath.."/default_settings.txt")
|
||||
dofile(modpath.."/settings.lua")
|
||||
|
||||
if io.open(worldpath.."/moretrees_settings.txt","r") then
|
||||
io.close()
|
||||
@ -95,111 +95,139 @@ dofile(modpath.."/saplings.lua")
|
||||
dofile(modpath.."/crafts.lua")
|
||||
|
||||
-- tree spawning setup
|
||||
moretrees.spawn_beech_object = moretrees.beech_model
|
||||
moretrees.spawn_apple_tree_object = moretrees.apple_tree_model
|
||||
moretrees.spawn_oak_object = moretrees.oak_model
|
||||
moretrees.spawn_sequoia_object = moretrees.sequoia_model
|
||||
moretrees.spawn_palm_object = moretrees.palm_model
|
||||
moretrees.spawn_date_palm_object = moretrees.date_palm_model
|
||||
moretrees.spawn_cedar_object = moretrees.cedar_model
|
||||
moretrees.spawn_rubber_tree_object = moretrees.rubber_tree_model
|
||||
moretrees.spawn_willow_object = moretrees.willow_model
|
||||
moretrees.spawn_birch_object = "moretrees.grow_birch"
|
||||
moretrees.spawn_spruce_object = "moretrees.grow_spruce"
|
||||
moretrees.spawn_jungletree_object = "moretrees.grow_jungletree"
|
||||
moretrees.spawn_fir_object = "moretrees.grow_fir"
|
||||
moretrees.spawn_fir_snow_object = "moretrees.grow_fir_snow"
|
||||
moretrees.spawn_poplar_object = moretrees.poplar_model
|
||||
moretrees.spawn_poplar_small_object = moretrees.poplar_small_model
|
||||
|
||||
if moretrees.spawn_saplings then
|
||||
moretrees.spawn_beech_object = "moretrees:beech_sapling_ongen"
|
||||
moretrees.spawn_apple_tree_object = "moretrees:apple_tree_sapling_ongen"
|
||||
moretrees.spawn_oak_object = "moretrees:oak_sapling_ongen"
|
||||
moretrees.spawn_sequoia_object = "moretrees:sequoia_sapling_ongen"
|
||||
moretrees.spawn_palm_object = "moretrees:palm_sapling_ongen"
|
||||
moretrees.spawn_date_palm_object = "moretrees:date_palm_sapling_ongen"
|
||||
moretrees.spawn_cedar_object = "moretrees:cedar_sapling_ongen"
|
||||
moretrees.spawn_rubber_tree_object = "moretrees:rubber_tree_sapling_ongen"
|
||||
moretrees.spawn_willow_object = "moretrees:willow_sapling_ongen"
|
||||
moretrees.spawn_birch_object = "moretrees:birch_sapling_ongen"
|
||||
moretrees.spawn_spruce_object = "moretrees:spruce_sapling_ongen"
|
||||
moretrees.spawn_jungletree_object = "moretrees:jungletree_sapling_ongen"
|
||||
moretrees.spawn_fir_object = "moretrees:fir_sapling_ongen"
|
||||
moretrees.spawn_fir_snow_object = "snow:sapling_pine"
|
||||
moretrees.spawn_poplar_object = "moretrees:poplar_sapling_ongen"
|
||||
moretrees.spawn_poplar_small_object = "moretrees:poplar_small_sapling_ongen"
|
||||
else
|
||||
moretrees.spawn_beech_object = moretrees.beech_model
|
||||
moretrees.spawn_apple_tree_object = moretrees.apple_tree_model
|
||||
moretrees.spawn_oak_object = moretrees.oak_model
|
||||
moretrees.spawn_sequoia_object = moretrees.sequoia_model
|
||||
moretrees.spawn_palm_object = moretrees.palm_model
|
||||
moretrees.spawn_date_palm_object = moretrees.date_palm_model
|
||||
moretrees.spawn_cedar_object = moretrees.cedar_model
|
||||
moretrees.spawn_rubber_tree_object = moretrees.rubber_tree_model
|
||||
moretrees.spawn_willow_object = moretrees.willow_model
|
||||
moretrees.spawn_birch_object = "moretrees.grow_birch"
|
||||
moretrees.spawn_spruce_object = "moretrees.grow_spruce"
|
||||
moretrees.spawn_jungletree_object = "moretrees.grow_jungletree"
|
||||
moretrees.spawn_fir_object = "moretrees.grow_fir"
|
||||
moretrees.spawn_fir_snow_object = "moretrees.grow_fir_snow"
|
||||
moretrees.spawn_poplar_object = moretrees.poplar_model
|
||||
moretrees.spawn_poplar_small_object = moretrees.poplar_small_model
|
||||
local deco_ids = {}
|
||||
|
||||
function translate_biome_defs(def, treename, index)
|
||||
if not index then index = 1 end
|
||||
local deco_def = {
|
||||
name = treename .. "_" .. index,
|
||||
deco_type = "simple",
|
||||
place_on = def.place_on or def.surface,
|
||||
sidelen = 16,
|
||||
fill_ratio = def.fill_ratio or 0.001,
|
||||
--biomes eventually?
|
||||
y_min = def.min_elevation,
|
||||
y_max = def.max_elevation,
|
||||
spawn_by = def.near_nodes,
|
||||
num_spawn_by = def.near_nodes_count,
|
||||
decoration = "moretrees:"..treename.."_sapling_ongen"
|
||||
}
|
||||
|
||||
deco_ids[#deco_ids+1] = treename .. ("_" .. index or "_1")
|
||||
|
||||
return deco_def
|
||||
end
|
||||
|
||||
if moretrees.enable_beech then
|
||||
biome_lib:register_generate_plant(moretrees.beech_biome, moretrees.spawn_beech_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.beech_biome, "beech"))
|
||||
end
|
||||
|
||||
if moretrees.enable_apple_tree then
|
||||
biome_lib:register_generate_plant(moretrees.apple_tree_biome, moretrees.spawn_apple_tree_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.apple_tree_biome, "apple_tree"))
|
||||
end
|
||||
|
||||
if moretrees.enable_oak then
|
||||
biome_lib:register_generate_plant(moretrees.oak_biome, moretrees.spawn_oak_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.oak_biome, "oak"))
|
||||
end
|
||||
|
||||
if moretrees.enable_sequoia then
|
||||
biome_lib:register_generate_plant(moretrees.sequoia_biome, moretrees.spawn_sequoia_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.sequoia_biome, "sequoia"))
|
||||
end
|
||||
|
||||
if moretrees.enable_palm then
|
||||
biome_lib:register_generate_plant(moretrees.palm_biome, moretrees.spawn_palm_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.palm_biome, "palm"))
|
||||
end
|
||||
|
||||
if moretrees.enable_date_palm then
|
||||
biome_lib:register_generate_plant(moretrees.date_palm_biome, moretrees.spawn_date_palm_object)
|
||||
biome_lib:register_generate_plant(moretrees.date_palm_biome_2, moretrees.spawn_date_palm_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.date_palm_biome, "palm", 1))
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.date_palm_biome_2, "palm", 2))
|
||||
end
|
||||
|
||||
if moretrees.enable_cedar then
|
||||
biome_lib:register_generate_plant(moretrees.cedar_biome, moretrees.spawn_cedar_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.cedar_biome, "cedar"))
|
||||
end
|
||||
|
||||
if moretrees.enable_rubber_tree then
|
||||
biome_lib:register_generate_plant(moretrees.rubber_tree_biome, moretrees.spawn_rubber_tree_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.rubber_tree_biome, "ruber"))
|
||||
end
|
||||
|
||||
if moretrees.enable_willow then
|
||||
biome_lib:register_generate_plant(moretrees.willow_biome, moretrees.spawn_willow_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.willow_biome, "willow"))
|
||||
end
|
||||
|
||||
if moretrees.enable_birch then
|
||||
biome_lib:register_generate_plant(moretrees.birch_biome, moretrees.spawn_birch_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.birch_biome, "birch"))
|
||||
end
|
||||
|
||||
if moretrees.enable_spruce then
|
||||
biome_lib:register_generate_plant(moretrees.spruce_biome, moretrees.spawn_spruce_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.spruce_biome, "spruce"))
|
||||
end
|
||||
|
||||
if moretrees.enable_jungle_tree then
|
||||
biome_lib:register_generate_plant(moretrees.jungletree_biome, moretrees.spawn_jungletree_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.jungletree_biome, "jungletree"))
|
||||
end
|
||||
|
||||
if moretrees.enable_fir then
|
||||
biome_lib:register_generate_plant(moretrees.fir_biome, moretrees.spawn_fir_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.fir_biome, "fir", 1))
|
||||
if minetest.get_modpath("snow") then
|
||||
biome_lib:register_generate_plant(moretrees.fir_biome_snow, moretrees.spawn_fir_snow_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.fir_biome_snow, "fir", 2))
|
||||
end
|
||||
end
|
||||
|
||||
if moretrees.enable_poplar then
|
||||
biome_lib:register_generate_plant(moretrees.poplar_biome, moretrees.spawn_poplar_object)
|
||||
biome_lib:register_generate_plant(moretrees.poplar_biome_2, moretrees.spawn_poplar_object)
|
||||
biome_lib:register_generate_plant(moretrees.poplar_biome_3, moretrees.spawn_poplar_object)
|
||||
biome_lib:register_generate_plant(moretrees.poplar_small_biome, moretrees.spawn_poplar_small_object)
|
||||
biome_lib:register_generate_plant(moretrees.poplar_small_biome_2, moretrees.spawn_poplar_small_object)
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.poplar_biome, "popular", 1))
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.poplar_biome_2, "popular", 2))
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.poplar_biome_3, "popular", 3))
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.poplar_small_biome, "popular", 4))
|
||||
minetest.register_decoration(translate_biome_defs(moretrees.poplar_small_biome_2, "popular", 5))
|
||||
end
|
||||
|
||||
for k, v in pairs(deco_ids) do
|
||||
deco_ids[k] = minetest.get_decoration_id(v)
|
||||
end
|
||||
minetest.set_gen_notify("decoration", deco_ids)
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
local g = minetest.get_mapgen_object("gennotify")
|
||||
--minetest.chat_send_all(dump(g))
|
||||
local locations = {}
|
||||
for _, id in pairs(deco_ids) do
|
||||
local deco_locations = g["decoration#" .. id] or {}
|
||||
for _, pos in pairs(deco_locations) do
|
||||
locations[#locations+1] = pos
|
||||
end
|
||||
end
|
||||
|
||||
if #locations == 0 then return end
|
||||
for _, pos in ipairs(locations) do
|
||||
--minetest.chat_send_all("yay")
|
||||
local timer = minetest.get_node_timer({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
timer:start(math.random(2,10))
|
||||
--minetest.set_node(pos, {name="default:stone"})
|
||||
end
|
||||
end)
|
||||
|
||||
-- Code to spawn a birch tree
|
||||
|
||||
function moretrees.grow_birch(pos)
|
||||
minetest.swap_node(pos, biome_lib.air)
|
||||
minetest.swap_node(pos, {name = "air"})
|
||||
if math.random(1,2) == 1 then
|
||||
minetest.spawn_tree(pos, moretrees.birch_model1)
|
||||
else
|
||||
@ -210,7 +238,7 @@ end
|
||||
-- Code to spawn a spruce tree
|
||||
|
||||
function moretrees.grow_spruce(pos)
|
||||
minetest.swap_node(pos, biome_lib.air)
|
||||
minetest.swap_node(pos, {name = "air"})
|
||||
if math.random(1,2) == 1 then
|
||||
minetest.spawn_tree(pos, moretrees.spruce_model1)
|
||||
else
|
||||
@ -225,6 +253,7 @@ moretrees.jt_rules_a1 = "FFF[&&-FBf[&&&Ff]^^^Ff][&&+FBFf[&&&FFf]^^^Ff][&&---FBFf
|
||||
moretrees.jt_rules_b1 = "[-Ff&f][+Ff&f]B"
|
||||
|
||||
moretrees.jt_axiom2 = "FFFFFA"
|
||||
-- luacheck: no max line length
|
||||
moretrees.jt_rules_a2 = "FFFFF[&&-FFFBF[&&&FFff]^^^FFf][&&+FFFBFF[&&&FFff]^^^FFf][&&---FFFBFF[&&&FFff]^^^FFf][&&+++FFFBFF[&&&FFff]^^^FFf]FF/A"
|
||||
moretrees.jt_rules_b2 = "[-FFf&ff][+FFf&ff]B"
|
||||
|
||||
@ -264,10 +293,13 @@ function moretrees.grow_jungletree(pos)
|
||||
moretrees.jungletree_model.rules_b = moretrees.jt_rules_b2
|
||||
end
|
||||
|
||||
minetest.swap_node(pos, biome_lib.air)
|
||||
local leaves = minetest.find_nodes_in_area({x = pos.x-1, y = pos.y, z = pos.z-1}, {x = pos.x+1, y = pos.y+10, z = pos.z+1}, "default:leaves")
|
||||
minetest.swap_node(pos, {name = "air"})
|
||||
local leaves = minetest.find_nodes_in_area(
|
||||
{x = pos.x-1, y = pos.y, z = pos.z-1}, {x = pos.x+1, y = pos.y+10, z = pos.z+1},
|
||||
"default:leaves"
|
||||
)
|
||||
for leaf in ipairs(leaves) do
|
||||
minetest.swap_node(leaves[leaf], biome_lib.air)
|
||||
minetest.swap_node(leaves[leaf], {name = "air"})
|
||||
end
|
||||
minetest.spawn_tree(pos, moretrees.jungletree_model)
|
||||
end
|
||||
@ -291,10 +323,14 @@ function moretrees.grow_fir(pos)
|
||||
moretrees.fir_model.iterations = 7
|
||||
moretrees.fir_model.random_level = 5
|
||||
|
||||
minetest.swap_node(pos, biome_lib.air)
|
||||
local leaves = minetest.find_nodes_in_area({x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y+5, z = pos.z}, "default:leaves")
|
||||
minetest.swap_node(pos, {name = "air"})
|
||||
local leaves = minetest.find_nodes_in_area(
|
||||
{x = pos.x, y = pos.y, z = pos.z},
|
||||
{x = pos.x, y = pos.y+5, z = pos.z},
|
||||
"default:leaves"
|
||||
)
|
||||
for leaf in ipairs(leaves) do
|
||||
minetest.swap_node(leaves[leaf], biome_lib.air)
|
||||
minetest.swap_node(leaves[leaf], {name = "air"})
|
||||
end
|
||||
minetest.spawn_tree(pos,moretrees.fir_model)
|
||||
end
|
||||
@ -318,10 +354,14 @@ function moretrees.grow_fir_snow(pos)
|
||||
moretrees.fir_model.iterations = 2
|
||||
moretrees.fir_model.random_level = 2
|
||||
|
||||
minetest.swap_node(pos, biome_lib.air)
|
||||
local leaves = minetest.find_nodes_in_area({x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y+5, z = pos.z}, "default:leaves")
|
||||
minetest.swap_node(pos, {name = "air"})
|
||||
local leaves = minetest.find_nodes_in_area(
|
||||
{x = pos.x, y = pos.y, z = pos.z},
|
||||
{x = pos.x, y = pos.y+5, z = pos.z},
|
||||
"default:leaves"
|
||||
)
|
||||
for leaf in ipairs(leaves) do
|
||||
minetest.swap_node(leaves[leaf], biome_lib.air)
|
||||
minetest.swap_node(leaves[leaf], {name = "air"})
|
||||
end
|
||||
minetest.spawn_tree(pos,moretrees.fir_model)
|
||||
end
|
||||
|
4
mod.conf
4
mod.conf
@ -1,4 +1,4 @@
|
||||
name = moretrees
|
||||
depends = default, biome_lib, vessels
|
||||
optional_depends = doors, stairs, moreblocks, farming
|
||||
depends = default, vessels
|
||||
optional_depends = doors, stairs, moreblocks, farming, ethereal
|
||||
min_minetest_version = 5.2.0
|
||||
|
@ -5,19 +5,19 @@ moretrees.avoidnodes = {}
|
||||
moretrees.treelist = {
|
||||
{"beech", S("Beech Tree")},
|
||||
{"apple_tree", S("Apple Tree")},
|
||||
{"oak", S("Oak Tree"), "acorn", S("Acorn"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
|
||||
{"oak", S("Oak Tree"), "acorn", S("Acorn"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
|
||||
{"sequoia", S("Giant Sequoia")},
|
||||
{"birch", S("Birch Tree")},
|
||||
{"palm", S("Palm Tree"), "palm_fruit_trunk_gen", S("Palm Tree"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 1.0 },
|
||||
{"date_palm", S("Date Palm Tree"), "date_palm_fruit_trunk", S("Date Palm Tree"), {0, 0, 0, 0, 0, 0}, 0.0 },
|
||||
{"spruce", S("Spruce Tree"), "spruce_cone", S("Spruce Cone"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
|
||||
{"cedar", S("Cedar Tree"), "cedar_cone", S("Cedar Cone"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
|
||||
{"palm", S("Palm Tree"), "palm_fruit_trunk_gen", S("Palm Tree"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 1.0 },
|
||||
{"date_palm", S("Date Palm Tree"), "date_palm_fruit_trunk",S("Date Palm Tree"), {0, 0, 0, 0, 0, 0}, 0.0 },
|
||||
{"spruce", S("Spruce Tree"), "spruce_cone", S("Spruce Cone"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
|
||||
{"cedar", S("Cedar Tree"), "cedar_cone", S("Cedar Cone"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
|
||||
{"poplar", S("Poplar Tree")},
|
||||
{"poplar_small", S("Poplar Tree")},
|
||||
{"willow", S("Willow Tree")},
|
||||
{"rubber_tree", S("Rubber Tree")},
|
||||
{"fir", S("Douglas Fir"), "fir_cone", S("Fir Cone"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
|
||||
{"jungletree", S("Jungle Tree"), nil, nil, nil, nil, "default_junglesapling.png" },
|
||||
{"fir", S("Douglas Fir"), "fir_cone", S("Fir Cone"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
|
||||
{"jungletree", S("Jungle Tree"), nil, nil, nil, nil, "default_junglesapling.png" },
|
||||
}
|
||||
|
||||
moretrees.treedesc = {
|
||||
@ -319,6 +319,23 @@ for i in ipairs(moretrees.treelist) do
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(300)
|
||||
end,
|
||||
on_timer = function(pos, elapsed)
|
||||
if moretrees.can_grow(pos, treename) then
|
||||
--moretrees["grow_" .. treename](pos)
|
||||
minetest.set_node(pos, {name="air"})
|
||||
if type(moretrees["spawn_" .. treename .. "_object"])=="string" then
|
||||
local split = moretrees["spawn_" .. treename .. "_object"]:split(".")
|
||||
moretrees[split[2]](pos)
|
||||
else
|
||||
minetest.spawn_tree(pos, moretrees["spawn_" .. treename .. "_object"])
|
||||
end
|
||||
else
|
||||
minetest.get_node_timer(pos):start(300)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local moretrees_leaves_inventory_image = nil
|
||||
@ -463,17 +480,34 @@ for i in ipairs(moretrees.treelist) do
|
||||
sounds = default.node_sound_defaults(),
|
||||
drop = "moretrees:"..treename.."_sapling",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
|
||||
"moretrees:" ..treename.. "_sapling_ongen",
|
||||
-- minp, maxp to be checked, relative to sapling pos
|
||||
-- minp_relative.y = 1 because sapling pos has been checked
|
||||
{x = -3, y = 1, z = -3},
|
||||
{x = 3, y = 6, z = 3},
|
||||
-- maximum interval of interior volume check
|
||||
4)
|
||||
itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
|
||||
"moretrees:" ..treename.. "_sapling_ongen",
|
||||
-- minp, maxp to be checked, relative to sapling pos
|
||||
-- minp_relative.y = 1 because sapling pos has been checked
|
||||
{x = -3, y = 1, z = -3},
|
||||
{x = 3, y = 6, z = 3},
|
||||
-- maximum interval of interior volume check
|
||||
4)
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(2)
|
||||
end,
|
||||
on_timer = function(pos, elapsed)
|
||||
if moretrees.can_grow(pos, treename) then
|
||||
--moretrees["grow_" .. treename](pos)
|
||||
minetest.set_node(pos, {name="air"})
|
||||
if type(moretrees["spawn_" .. treename .. "_object"])=="string" then
|
||||
local split = moretrees["spawn_" .. treename .. "_object"]:split(".")
|
||||
moretrees[split[2]](pos)
|
||||
else
|
||||
minetest.spawn_tree(pos, moretrees["spawn_" .. treename .. "_object"])
|
||||
end
|
||||
else
|
||||
minetest.get_node_timer(pos):start(300)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local fruitname = nil
|
||||
|
25
saplings.lua
25
saplings.lua
@ -39,7 +39,28 @@ local sand_surfaces = {
|
||||
-- too cold for a palm, too... well... sandy for anything else.
|
||||
}
|
||||
|
||||
for i in ipairs(moretrees.treelist) do
|
||||
function moretrees.can_grow(pos, treename)
|
||||
local surfaces
|
||||
|
||||
if treename == "spruce"
|
||||
or treename == "fir"
|
||||
or treename == "cedar"
|
||||
or treename == "pine" then
|
||||
surfaces = conifer_surfaces
|
||||
elseif string.find(treename, "palm") then
|
||||
surfaces = sand_surfaces
|
||||
else
|
||||
surfaces = dirt_surfaces
|
||||
end
|
||||
|
||||
if surfaces[minetest.get_node(vector.new(pos.x, pos.y-1, pos.z)).name] then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
--[[ for i in ipairs(moretrees.treelist) do
|
||||
local treename = moretrees.treelist[i][1]
|
||||
local tree_model = treename.."_model"
|
||||
local tree_biome = treename.."_biome"
|
||||
@ -81,4 +102,4 @@ for i in ipairs(moretrees.treelist) do
|
||||
grow_nodes = surfaces,
|
||||
grow_function = grow_function,
|
||||
})
|
||||
end
|
||||
end ]]
|
||||
|
@ -145,7 +145,8 @@ minetest.register_chatcommand("make-scene", {
|
||||
The following is a search/replace command suitable for vi (/vim) or sed, to convert minetest log
|
||||
messages to equivalent lua commands:
|
||||
|
||||
s/.*\(\(moretrees\|default\)[^ ]*\) at (\([-0-9]\+\),\([-0-9]\+\),\([-0-9]\+\)).*/\t\tminetest.place_node({x=\3, y=\4, z=\5}, {name="\1"})/
|
||||
s/.*\(\(moretrees\|default\)[^ ]*\) at
|
||||
(\([-0-9]\+\),\([-0-9]\+\),\([-0-9]\+\)).*/\t\tminetest.place_node({x=\3, y=\4, z=\5}, {name="\1"})/
|
||||
|
||||
E.g. a minetest log line of the following kind:
|
||||
2016-07-03 11:30:50: ACTION[Server]: singleplayer places node moretrees:rubber_tree_sapling at (760,5,-223)
|
||||
|
79
settings.lua
Normal file
79
settings.lua
Normal file
@ -0,0 +1,79 @@
|
||||
local stg = minetest.settings
|
||||
|
||||
--enable/disable different trees
|
||||
moretrees.enable_apple_tree = stg:get_bool("moretrees.enable_apple_tree", true)
|
||||
moretrees.enable_oak = stg:get_bool("moretrees.enable_oak", true)
|
||||
moretrees.enable_sequoia = stg:get_bool("moretrees.enable_sequoia", true)
|
||||
moretrees.enable_palm = stg:get_bool("moretrees.enable_palm", true)
|
||||
moretrees.enable_date_palm = stg:get_bool("moretrees.enable_date_palm", true)
|
||||
moretrees.enable_cedar = stg:get_bool("moretrees.enable_cedar", true)
|
||||
moretrees.enable_rubber_tree = stg:get_bool("moretrees.enable_rubber_tree", true)
|
||||
moretrees.enable_willow = stg:get_bool("moretrees.enable_willow", true)
|
||||
moretrees.enable_birch = stg:get_bool("moretrees.enable_birch", true)
|
||||
moretrees.enable_spruce = stg:get_bool("moretrees.enable_spruce", true)
|
||||
moretrees.enable_jungle_tree = stg:get_bool("moretrees.enable_jungle_tree", true)
|
||||
moretrees.enable_fir = stg:get_bool("moretrees.enable_fir", true)
|
||||
moretrees.enable_poplar = stg:get_bool("moretrees.enable_poplar", true)
|
||||
moretrees.enable_beech = stg:get_bool("moretrees.enable_beech", false)
|
||||
|
||||
--spawns tree on mapgen as saplings, legacy setting
|
||||
moretrees.spawn_saplings = stg:get_bool("moretrees.spawn_saplings", true)
|
||||
|
||||
--turn on/off stair varients of nodes via moreblocks or the stair api
|
||||
moretrees.enable_stairs = stg:get_bool("moretrees.enable_stairs", true)
|
||||
|
||||
-- If this variable is set to true, register fences for moretrees wood
|
||||
moretrees.enable_fences = stg:get_bool("moretrees.enable_fences", true)
|
||||
|
||||
--enable plantlike drawtype for leaves
|
||||
moretrees.plantlike_leaves = stg:get_bool("moretrees.plantlike_leaves", false)
|
||||
|
||||
-- Enable this if you want moretrees to redefine default apples so that they
|
||||
-- fall when leaves decay/are dug.
|
||||
moretrees.enable_redefine_apple = stg:get_bool("moretrees.enable_redefine_apple", true)
|
||||
|
||||
-- Set this to true to enable leaf decay of all trees except the default ones.
|
||||
moretrees.enable_leafdecay = stg:get_bool("moretrees.enable_leafdecay", true)
|
||||
|
||||
-- various related settings to configure leaf decay.
|
||||
moretrees.leafdecay_delay = tonumber(stg:get("moretrees.leafdecay_delay")) or 2
|
||||
moretrees.leafdecay_chance = tonumber(stg:get("moretrees.leafdecay_chance")) or 5
|
||||
moretrees.leafdecay_radius = tonumber(stg:get("moretrees.leafdecay_radius")) or 5
|
||||
moretrees.palm_leafdecay_radius = tonumber(stg:get("moretrees.palm_leafdecay_radius")) or 10
|
||||
moretrees.date_palm_leafdecay_radius = tonumber(stg:get("moretrees.date_palm_leafdecay_radius")) or 14
|
||||
|
||||
-- Change these settings if you want default trees to be gradually cut down
|
||||
-- above the elevation where firs normally generate.
|
||||
moretrees.firs_remove_default_trees = stg:get_bool("moretrees.firs_remove_default_trees", false)
|
||||
moretrees.firs_remove_interval = tonumber(stg:get("moretrees.firs_remove_interval")) or 2
|
||||
moretrees.firs_remove_chance = tonumber(stg:get("moretrees.firs_remove_chance")) or 150
|
||||
|
||||
-- Cocos palm settings
|
||||
moretrees.coconuts_regrow = stg:get_bool("moretrees.coconuts_regrow", true)
|
||||
moretrees.coconuts_convert_existing_palms = stg:get_bool("moretrees.coconuts_convert_existing_palms", true)
|
||||
moretrees.coconut_flower_interval = tonumber(stg:get("moretrees.coconut_flower_interval")) or 59
|
||||
moretrees.coconut_flower_chance = tonumber(stg:get("moretrees.coconut_flower_chance")) or 67
|
||||
moretrees.coconut_grow_interval = tonumber(stg:get("moretrees.coconut_grow_interval")) or
|
||||
2 * moretrees.coconut_flower_interval * moretrees.coconut_flower_chance
|
||||
moretrees.coconut_item_drop_ichance = tonumber(stg:get("moretrees.coconut_item_drop_ichance")) or 10
|
||||
|
||||
-- Date palm settings
|
||||
moretrees.dates_regrow_pollinated = stg:get_bool("moretrees.dates_regrow_pollinated", true)
|
||||
moretrees.dates_regrow_unpollinated_percent = tonumber(stg:get("moretrees.dates_regrow_unpollinated_percent")) or 0
|
||||
moretrees.dates_female_percent = tonumber(stg:get("moretrees.dates_female_percent")) or 57
|
||||
moretrees.dates_pollination_distance = tonumber(stg:get("moretrees.dates_pollination_distance")) or 120
|
||||
moretrees.dates_blossom_search_time_treshold = tonumber(stg:get("moretrees.dates_blossom_search_time_treshold")) or 1000
|
||||
moretrees.dates_blossom_search_iload = tonumber(stg:get("moretrees.dates_blossom_search_iload")) or 10
|
||||
moretrees.dates_flower_interval = tonumber(stg:get("moretrees.dates_flower_interval")) or 59
|
||||
moretrees.dates_flower_chance = tonumber(stg:get("moretrees.dates_flower_chance")) or 181
|
||||
moretrees.dates_grow_interval = tonumber(stg:get("moretrees.dates_grow_interval")) or
|
||||
2 * moretrees.dates_flower_interval * moretrees.dates_flower_chance
|
||||
moretrees.dates_item_drop_ichance = tonumber(stg:get("moretrees.dates_item_drop_ichance")) or 10
|
||||
|
||||
-- Sapling settings
|
||||
moretrees.sapling_interval = 100
|
||||
moretrees.sapling_chance = 5
|
||||
|
||||
-- If this variable is set to true, drop leaves out as entities during leaf
|
||||
-- decay, rather than just disappearing them.
|
||||
moretrees.decay_leaves_as_items = stg:get_bool("moretrees.decay_leaves_as_items", false)
|
@ -1,5 +1,6 @@
|
||||
moretrees.beech_model={
|
||||
axiom="FFFFFBFB",
|
||||
-- luacheck: no max line length
|
||||
rules_a="[&&&GGF[++^Fd][--&Fd]//Fd[+^Fd][--&Fd]]////[&&&GGF[++^Fd][--&Fd]//Fd[+^Fd][--&Fd]]////[&&&GGF[++^Fd][--&Fd]//Fd[+^Fd][--&Fdd]]",
|
||||
rules_b="[&&&F[++^Fd][--&d]//d[+^d][--&d]]////[&&&F[++^Fd][--&d]//d[+^d][--&d]]////[&&&F[++^Fd][--&Fd]//d[+^d][--&d]]",
|
||||
rules_c="/",
|
||||
@ -75,6 +76,7 @@ moretrees.poplar_small_model={
|
||||
|
||||
moretrees.sequoia_model={
|
||||
axiom="FFFFFFFFFFddccA///cccFddcFA///ddFcFA/cFFddFcdBddd/A/ccdcddd/ccAddddcFBcccAccFdFcFBcccc/BFdFFcFFdcccc/B",
|
||||
-- luacheck: no max line length
|
||||
rules_a="[&&&GGF[++^FFdd][--&Fddd]//Fdd[+^Fd][--&Fdd]]////[&&&GGF[++^FFdd][--&Fddd]//Fdd[+^Fd][--&Fdd]]////[&&&GGF[++^FFdd][--&Fddd]//Fdd[+^Fd][--&Fdd]]",
|
||||
rules_b="[&&&GGF[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]////[&&&GGF[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]////[&&&GGF[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]",
|
||||
rules_c="/",
|
||||
@ -166,6 +168,7 @@ moretrees.date_palm_model={
|
||||
}
|
||||
|
||||
moretrees.spruce_model1={
|
||||
-- luacheck: no max line length
|
||||
axiom="FFFFFAFFFFFFBFFFFFFCFFFFFFDFFFFFF[&&&F^^FF][&&&++F^^FF][&&&++++F^^FF][&&&++++++F^^FF][&&&--F^^FF][&&&----F^^FF][FFFFf]",
|
||||
rules_a="[&&&FFFFFF^^FFF][&&&++FFFFFF^^FFF][&&&++++FFFFFF^^FFF][&&&++++++FFFFFF^^FFF][&&&--FFFFFF^^FFF][&&&----FFFFFF^^FFF]",
|
||||
rules_b="[&&&FFFFF^^FFF][&&&++FFFFF^^FFF][&&&++++FFFFF^^FFF][&&&++++++FFFFF^^FFF][&&&--FFFFF^^FFF][&&&----FFFFF^^FFF]",
|
||||
@ -183,6 +186,7 @@ moretrees.spruce_model1={
|
||||
}
|
||||
|
||||
moretrees.spruce_model2={
|
||||
-- luacheck: no max line length
|
||||
axiom="FFFFFFBFFFFFFCFFFFFFDFFFFFF[&&&F^^FF][&&&++F^^FF][&&&++++F^^FF][&&&++++++F^^FF][&&&--F^^FF][&&&----F^^FF][FFFFf]",
|
||||
rules_b="[&&&FFFFF^^FFF][&&&++FFFFF^^FFF][&&&++++FFFFF^^FFF][&&&++++++FFFFF^^FFF][&&&--FFFFF^^FFF][&&&----FFFFF^^FFF]",
|
||||
rules_c="[&&&FFFF^^FFF][&&&++FFFF^^FFF][&&&++++FFFF^^FFF][&&&++++++FFFF^^FFF][&&&--FFFF^^FFF][&&&----FFFF^^FFF]",
|
||||
@ -217,6 +221,7 @@ moretrees.cedar_model={
|
||||
|
||||
moretrees.willow_model={
|
||||
axiom="FFFFFFFFccA",
|
||||
-- luacheck: no max line length
|
||||
rules_a="[&FF&FFFF&&F&FFFFFFFdddd][**&FF&FFFF&&F&FFFFFFFdddd][//&FF&FFFF&&F&FFFFFFFdddd][////&FF&FFFF&&F&FFFFFFFdddd][//////&FF&FFFF&&F&FFFFFFFdddd][////////&FF&FFFF&&F&FFFFFFFdddd]",
|
||||
rules_c="/",
|
||||
rules_d="F",
|
||||
|
Loading…
Reference in New Issue
Block a user