Compare commits
No commits in common. "wip" and "main" have entirely different histories.
@ -1,22 +1,16 @@
|
|||||||
ebiometrees.registered_trees = {}
|
ebiometrees.registered_trees = {}
|
||||||
|
|
||||||
function ebiometrees.register_tree(name, treespec)
|
function ebiometrees.register_tree(name, data)
|
||||||
ebiometrees.registered_trees[name] = treespec
|
ebiometrees.registered_trees[name] = data
|
||||||
ebiometrees.register_subnodes(name)
|
ebiometrees.register_subnodes(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ebiometrees.register_subnodes(tree_name)
|
function ebiometrees.register_subnodes(tree_name)
|
||||||
local modname = tree_name:match("([^:]*):")
|
local modname = tree_name:match("([^:]*):")
|
||||||
local basename = tree_name:match(":([^:]+)")
|
local basename = tree_name:match(":([^:]+)")
|
||||||
local treespec = ebiometrees.registered_trees[tree_name]
|
local data = ebiometrees.registered_trees[tree_name]
|
||||||
ebiometrees.register_tree_sapling(modname, basename, treespec)
|
ebiometrees.register_tree_sapling(modname, basename, data)
|
||||||
ebiometrees.register_tree_sprout(modname, basename, treespec)
|
ebiometrees.register_tree_sprout(modname, basename, data)
|
||||||
ebiometrees.register_tree_leaves(modname, basename, treespec)
|
ebiometrees.register_tree_leaves(modname, basename, data)
|
||||||
ebiometrees.register_tree_trunks(modname, basename, treespec)
|
ebiometrees.register_tree_trunks(modname, basename, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ebiometrees.get_tree_leaves(tree_name)
|
|
||||||
return tree_name.."_leaves"
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,8 +17,10 @@ function ebiometrees.where_to_grow_trunk_closure(grow_preferences, leaves_name)
|
|||||||
corner1 = pos:add({x=-1, y=-1, z=-1}):add(candidate_dir:multiply(2))
|
corner1 = pos:add({x=-1, y=-1, z=-1}):add(candidate_dir:multiply(2))
|
||||||
corner2 = pos:add({x= 1, y= 1, z= 1}):add(candidate_dir:multiply(2))
|
corner2 = pos:add({x= 1, y= 1, z= 1}):add(candidate_dir:multiply(2))
|
||||||
local spacious, _ = minetest.find_nodes_in_area(
|
local spacious, _ = minetest.find_nodes_in_area(
|
||||||
corner1, corner2, {"group:treetrunk", "group:dirt" }
|
corner1, corner2, "group:treetrunk"
|
||||||
)
|
)
|
||||||
|
minetest.chat_send_all(dump2(spacious))
|
||||||
|
minetest.chat_send_all(#spacious)
|
||||||
if node and node.name == leaves_name and #spacious == 0
|
if node and node.name == leaves_name and #spacious == 0
|
||||||
then
|
then
|
||||||
return candidate
|
return candidate
|
||||||
@ -43,7 +45,6 @@ function ebiometrees.grow_trunk_closure(trunk_terminal_name, grow_preferences, l
|
|||||||
minetest.set_node(there, {name=trunk_terminal_name})
|
minetest.set_node(there, {name=trunk_terminal_name})
|
||||||
local newmeta = minetest.get_meta(there)
|
local newmeta = minetest.get_meta(there)
|
||||||
newmeta:set_int("ebiometrees:distance", meta:get_int("ebiometrees:distance")+1)
|
newmeta:set_int("ebiometrees:distance", meta:get_int("ebiometrees:distance")+1)
|
||||||
meta:set_int("ebiometrees:distance", meta:get_int("ebiometrees:distance")+1)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return grow_trunk
|
return grow_trunk
|
||||||
@ -62,17 +63,11 @@ function ebiometrees.grow_leaves_closure(leaves_name)
|
|||||||
return grow_leaves
|
return grow_leaves
|
||||||
end
|
end
|
||||||
|
|
||||||
function ebiometrees.tree_timer_lifecycle_closure(tree_name)
|
|
||||||
leaves_name = tree_name.."_leaves"
|
|
||||||
terminal_name = tree_name.."_trunk_growing_terminal"
|
|
||||||
nextstage = tree_name.."_trunk_normal_terminal"
|
|
||||||
grow_preferences = ebiometrees.registered_trees[tree_name]["growth_preferences"]
|
|
||||||
age_max = ebiometrees.registered_trees[tree_name]["age_max"]
|
|
||||||
grow_limit = ebiometrees.registered_trees[tree_name]["growth_limit"]
|
|
||||||
|
|
||||||
|
function ebiometrees.tree_grower(leaves_name, grow_preferences, terminal_name, nextstage, age_max, grow_limit)
|
||||||
local grow_trunk = ebiometrees.grow_trunk_closure(terminal_name, grow_preferences, leaves_name, grow_limit)
|
local grow_trunk = ebiometrees.grow_trunk_closure(terminal_name, grow_preferences, leaves_name, grow_limit)
|
||||||
local grow_leaves = ebiometrees.grow_leaves_closure(leaves_name)
|
local grow_leaves = ebiometrees.grow_leaves_closure(leaves_name)
|
||||||
function tree_timer_lifecycle(pos)
|
local function grow_tree(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_int("ebiometrees:age", meta:get_int("ebiometrees:age")+1)
|
meta:set_int("ebiometrees:age", meta:get_int("ebiometrees:age")+1)
|
||||||
grow_trunk(pos)
|
grow_trunk(pos)
|
||||||
@ -86,6 +81,6 @@ function ebiometrees.tree_timer_lifecycle_closure(tree_name)
|
|||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return tree_timer_lifecycle
|
return grow_tree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,24 +6,14 @@ local function growth_timer(pos)
|
|||||||
meta:set_int("ebiometrees:age", 0)
|
meta:set_int("ebiometrees:age", 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setup_trunk_closure(treespec)
|
function ebiometrees.register_tree_leaves(modname, basename, data)
|
||||||
local function setup_trunk(pos)
|
|
||||||
minetest.get_node_timer(pos):start(3)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:mark_as_private("ebiometrees:age")
|
|
||||||
meta:mark_as_private("ebiometrees:life")
|
|
||||||
meta:set_int("ebiometrees:age", 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function ebiometrees.register_tree_leaves(modname, basename, treespec)
|
|
||||||
local S = minetest.get_translator(modname)
|
local S = minetest.get_translator(modname)
|
||||||
local leaves_groups = table.copy(treespec.groups)
|
local leaves_groups = table.copy(data.groups)
|
||||||
leaves_groups.leaves = 1
|
leaves_groups.leaves = 1
|
||||||
leaves_groups.leafdecay = 3
|
leaves_groups.leafdecay = 3
|
||||||
leaves_groups.snappy = 3
|
leaves_groups.snappy = 3
|
||||||
minetest.register_node(modname..":"..basename.."_leaves", {
|
minetest.register_node(modname..":"..basename.."_leaves", {
|
||||||
description = S(treespec.description.." leaves"),
|
description = S(data.description.." leaves"),
|
||||||
drawtype = "allfaces_optional",
|
drawtype = "allfaces_optional",
|
||||||
waving = 1,
|
waving = 1,
|
||||||
tiles = { modname.."_"..basename.."_leaves.png" },
|
tiles = { modname.."_"..basename.."_leaves.png" },
|
||||||
@ -34,15 +24,15 @@ function ebiometrees.register_tree_leaves(modname, basename, treespec)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ebiometrees.register_tree_sapling(modname, basename, treespec)
|
function ebiometrees.register_tree_sapling(modname, basename, data)
|
||||||
-- register saplings
|
-- register saplings
|
||||||
local S = minetest.get_translator(modname)
|
local S = minetest.get_translator(modname)
|
||||||
local sapling_groups = table.copy(treespec.groups)
|
local sapling_groups = table.copy(data.groups)
|
||||||
sapling_groups.sapling = 1
|
sapling_groups.sapling = 1
|
||||||
sapling_groups.snappy = 2
|
sapling_groups.snappy = 2
|
||||||
sapling_groups.dig_immediate = 3
|
sapling_groups.dig_immediate = 3
|
||||||
minetest.register_node(modname..":"..basename.."_sapling", {
|
minetest.register_node(modname..":"..basename.."_sapling", {
|
||||||
description = S(treespec.description.." sapling"),
|
description = S(data.description.." sapling"),
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
tiles = { modname.."_"..basename.."_sapling.png"},
|
tiles = { modname.."_"..basename.."_sapling.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -56,14 +46,14 @@ function ebiometrees.register_tree_sapling(modname, basename, treespec)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ebiometrees.register_tree_sprout(modname, basename, treespec)
|
function ebiometrees.register_tree_sprout(modname, basename, data)
|
||||||
-- register tree leaves
|
-- register tree leaves
|
||||||
local S = minetest.get_translator(modname)
|
local S = minetest.get_translator(modname)
|
||||||
local sprout_groups = table.copy(treespec.groups)
|
local sprout_groups = table.copy(data.groups)
|
||||||
sprout_groups.sapling = 1
|
sprout_groups.sapling = 1
|
||||||
sprout_groups.snappy = 2
|
sprout_groups.snappy = 2
|
||||||
minetest.register_node(modname..":"..basename.."_sprout", {
|
minetest.register_node(modname..":"..basename.."_sprout", {
|
||||||
description = S(treespec.description.." sprout"),
|
description = S(data.description.." sprout"),
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
visual_scale = 1.4,
|
visual_scale = 1.4,
|
||||||
tiles = { modname.."_"..basename.."_sprout.png" },
|
tiles = { modname.."_"..basename.."_sprout.png" },
|
||||||
@ -78,10 +68,10 @@ function ebiometrees.register_tree_sprout(modname, basename, treespec)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ebiometrees.register_tree_trunks(modname, basename, treespec)
|
function ebiometrees.register_tree_trunks(modname, basename, data)
|
||||||
local S = minetest.get_translator(modname)
|
local S = minetest.get_translator(modname)
|
||||||
-- registers corresponding trunk nodes
|
-- registers corresponding trunk nodes
|
||||||
local trunk_groups = table.copy(treespec.groups)
|
local trunk_groups = table.copy(data.groups)
|
||||||
trunk_groups.choppy = 2 -- TODO: customizations
|
trunk_groups.choppy = 2 -- TODO: customizations
|
||||||
trunk_groups.treetrunk = 1
|
trunk_groups.treetrunk = 1
|
||||||
local trunk_types = {"growing", "normal"}
|
local trunk_types = {"growing", "normal"}
|
||||||
@ -150,7 +140,7 @@ function ebiometrees.register_tree_trunks(modname, basename, treespec)
|
|||||||
for _, trunk_subtype in ipairs(trunk_subtypes)
|
for _, trunk_subtype in ipairs(trunk_subtypes)
|
||||||
do
|
do
|
||||||
local nodespec = {
|
local nodespec = {
|
||||||
description = S(treespec.description.." "..trunk_type.." "..trunk_subtype),
|
description = S(data.description.." "..trunk_type.." "..trunk_subtype),
|
||||||
groups = trunk_groups,
|
groups = trunk_groups,
|
||||||
tiles = subtype_tiles[trunk_subtype],
|
tiles = subtype_tiles[trunk_subtype],
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
@ -160,7 +150,22 @@ function ebiometrees.register_tree_trunks(modname, basename, treespec)
|
|||||||
}
|
}
|
||||||
if trunk_type == "growing"
|
if trunk_type == "growing"
|
||||||
then
|
then
|
||||||
nodespec.on_timer = ebiometrees.tree_timer_lifecycle_closure(modname..":"..basename)
|
nodespec.on_timer = ebiometrees.tree_grower(
|
||||||
|
modname..":"..basename.."_leaves",
|
||||||
|
{
|
||||||
|
{ebiometrees.directions.up},
|
||||||
|
{
|
||||||
|
ebiometrees.directions.north,
|
||||||
|
ebiometrees.directions.east,
|
||||||
|
ebiometrees.directions.south,
|
||||||
|
ebiometrees.directions.west
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modname..":"..basename.."_trunk_growing_terminal",
|
||||||
|
modname..":"..basename.."_trunk_normal_"..trunk_subtype,
|
||||||
|
20,
|
||||||
|
10
|
||||||
|
)
|
||||||
end
|
end
|
||||||
minetest.register_node(
|
minetest.register_node(
|
||||||
modname..":"..basename.."_trunk_"..trunk_type.."_"..trunk_subtype,
|
modname..":"..basename.."_trunk_"..trunk_type.."_"..trunk_subtype,
|
||||||
|
@ -12,19 +12,7 @@ minetest.register_biome({
|
|||||||
})
|
})
|
||||||
ebiometrees.register_tree("electric_biomes:oak",{
|
ebiometrees.register_tree("electric_biomes:oak",{
|
||||||
description = "Oak",
|
description = "Oak",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2}
|
||||||
life = 30,
|
|
||||||
growth_preferences = {
|
|
||||||
{ebiometrees.directions.up},
|
|
||||||
{
|
|
||||||
ebiometrees.directions.north,
|
|
||||||
ebiometrees.directions.east,
|
|
||||||
ebiometrees.directions.south,
|
|
||||||
ebiometrees.directions.west
|
|
||||||
}
|
|
||||||
},
|
|
||||||
growth_limit = 10,
|
|
||||||
age_max = 20,
|
|
||||||
})
|
})
|
||||||
minetest.register_node("electric_biomes:grass", {
|
minetest.register_node("electric_biomes:grass", {
|
||||||
description = S("Grass"),
|
description = S("Grass"),
|
||||||
|
Loading…
Reference in New Issue
Block a user