diff --git a/mods/ebiome/biomes/grasslands.lua b/mods/ebiome/biomes/grasslands.lua index 6b9d83c..b3b9f59 100644 --- a/mods/ebiome/biomes/grasslands.lua +++ b/mods/ebiome/biomes/grasslands.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("eterrain") +local S = minetest.get_translator("ebiome") minetest.register_biome({ name = "grasslands", node_top = "mapgen_topsoil", @@ -10,74 +10,9 @@ minetest.register_biome({ heat_point = 50, humidity_point = 50, }) -minetest.register_node("ebiome:oak_sapling", { - description = S("Oak tree sapling"), - drawtype = "plantlike", - tiles = { "ebiome_oak_sapling.png" }, - paramtype = "light", - on_timer = ebiometrees.get_sapling_grower("ebiome:oak_sprout"), - sunlight_propagates = true, - walkable = false, - groups = {snappy = 2, dig_immediate = 3, flammable = 2, - attached_node = 1, sapling = 1}, - on_construct = function(pos) - minetest.get_node_timer(pos):start(3) - end -}) -minetest.register_node("ebiome:oak_sprout", { - description = S("Oak tree sprout"), - drawtype = "plantlike", - visual_scale = 1.4, - tiles = { "ebiome_oak_sprout.png" }, - paramtype = "light", - sunlight_propagates = true, - walkable = false, - on_timer = ebiometrees.get_sprout_grower("ebiome:oak_trunk_normal", "ebiome:oak_trunk_growing"), - groups = {snappy = 3, dig_immediate = 3, flammable = 2, - attached_node = 1}, - on_construct = function(pos) - minetest.get_node_timer(pos):start(3) - end -}) -minetest.register_node("ebiome:oak_trunk_growing", { - description = S("Oak tree trunk"), - tiles = { "ebiome_oak_trunk_growing.png", - "ebiome_oak_trunk_slice_normal.png", - "ebiome_oak_trunk_growing.png" - }, - paramtype2 = "facedir", - is_ground_content = false, - groups = {tree = 1, choppy = 2, flammable = 2}, - on_place = minetest.rotate_node, - on_timer = function(pos) - return true - end, - on_construct = function(pos) - minetest.get_node_timer(pos):start(3) - end -}) -minetest.register_node("ebiome:oak_trunk_normal", { - description = S("Oak tree trunk"), - tiles = { "ebiome_oak_trunk_slice_normal.png", "ebiome_oak_trunk_slice_normal.png","ebiome_oak_trunk_normal.png"}, - paramtype2 = "facedir", - is_ground_content = false, - groups = {tree = 1, choppy = 2, flammable = 2}, - on_place = minetest.rotate_node -}) -minetest.register_node("ebiome:oak_trunk_normal_corner", { - description = S("Oak tree trunk corner branch"), - tiles = { - "ebiome_oak_trunk_normal.png", - "ebiome_oak_trunk_slice_normal.png", - "ebiome_oak_trunk_corner_normal.png^[transformFX", - "ebiome_oak_trunk_corner_normal.png", - "ebiome_oak_trunk_normal.png", - "ebiome_oak_trunk_slice_normal.png", - }, - paramtype2 = "facedir", - is_ground_content = false, - groups = {tree = 1, choppy = 2, flammable = 2}, - on_place = minetest.rotate_node +ebiometrees.register_tree("ebiome", "oak",{ + description = "Oak", + groups = {flammable = 2} }) minetest.register_node("ebiome:grass", { description = S("Grass"), diff --git a/mods/ebiome/textures/ebiome_oak_trunk_growing_corner.png b/mods/ebiome/textures/ebiome_oak_trunk_growing_corner.png new file mode 100644 index 0000000..5977d69 Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_growing_corner.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_growing_normal.png b/mods/ebiome/textures/ebiome_oak_trunk_growing_normal.png new file mode 100644 index 0000000..b96258f Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_growing_normal.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_growing_slice.png b/mods/ebiome/textures/ebiome_oak_trunk_growing_slice.png new file mode 100644 index 0000000..dfde79e Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_growing_slice.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_growing.png b/mods/ebiome/textures/ebiome_oak_trunk_growing_terminal.png similarity index 100% rename from mods/ebiome/textures/ebiome_oak_trunk_growing.png rename to mods/ebiome/textures/ebiome_oak_trunk_growing_terminal.png diff --git a/mods/ebiome/textures/ebiome_oak_trunk_growing_tjunction.png b/mods/ebiome/textures/ebiome_oak_trunk_growing_tjunction.png new file mode 100644 index 0000000..fa16c75 Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_growing_tjunction.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_growing_xjunction.png b/mods/ebiome/textures/ebiome_oak_trunk_growing_xjunction.png new file mode 100644 index 0000000..4adf4cc Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_growing_xjunction.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_corner_normal.png b/mods/ebiome/textures/ebiome_oak_trunk_normal_corner.png similarity index 100% rename from mods/ebiome/textures/ebiome_oak_trunk_corner_normal.png rename to mods/ebiome/textures/ebiome_oak_trunk_normal_corner.png diff --git a/mods/ebiome/textures/ebiome_oak_trunk_normal.png b/mods/ebiome/textures/ebiome_oak_trunk_normal_normal.png similarity index 100% rename from mods/ebiome/textures/ebiome_oak_trunk_normal.png rename to mods/ebiome/textures/ebiome_oak_trunk_normal_normal.png diff --git a/mods/ebiome/textures/ebiome_oak_trunk_slice_normal.png b/mods/ebiome/textures/ebiome_oak_trunk_normal_slice.png similarity index 100% rename from mods/ebiome/textures/ebiome_oak_trunk_slice_normal.png rename to mods/ebiome/textures/ebiome_oak_trunk_normal_slice.png diff --git a/mods/ebiome/textures/ebiome_oak_trunk_normal_terminal.png b/mods/ebiome/textures/ebiome_oak_trunk_normal_terminal.png new file mode 100644 index 0000000..39ca1ee Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_normal_terminal.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_normal_tjunction.png b/mods/ebiome/textures/ebiome_oak_trunk_normal_tjunction.png new file mode 100644 index 0000000..1bd4d9d Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_normal_tjunction.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_normal_xjunction.png b/mods/ebiome/textures/ebiome_oak_trunk_normal_xjunction.png new file mode 100644 index 0000000..a727c99 Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_normal_xjunction.png differ diff --git a/mods/ebiometrees/init.lua b/mods/ebiometrees/init.lua index 831ba60..c3df1cb 100644 --- a/mods/ebiometrees/init.lua +++ b/mods/ebiometrees/init.lua @@ -1 +1,2 @@ dofile(minetest.get_modpath("ebiometrees").."/sapling.lua") +dofile(minetest.get_modpath("ebiometrees").."/tree.lua") diff --git a/mods/ebiometrees/tree.lua b/mods/ebiometrees/tree.lua new file mode 100644 index 0000000..ce55c77 --- /dev/null +++ b/mods/ebiometrees/tree.lua @@ -0,0 +1,128 @@ +local function growth_timer(pos) + minetest.get_node_timer(pos):start(3) +end + + +local S = minetest.get_translator("ebiometrees") +function ebiometrees.register_tree(modname, basename, data) + -- register saplings + local sapling_name = modname..":"..basename.."_sapling" + local sprout_name = modname..":"..basename.."_sprout" + + local sapling_groups = table.copy(data.groups) + local sprout_groups = table.copy(data.groups) + sapling_groups.sapling = 1 + sapling_groups.snappy = 2 + sapling_groups.dig_immediate = 3 + sprout_groups.sapling = 1 + sprout_groups.snappy = 2 + minetest.register_node(sapling_name, { + description = S(data.description.." sapling"), + drawtype = "plantlike", + tiles = { modname.."_"..basename.."_sapling.png"}, + paramtype = "light", + on_timer = ebiometrees.get_sapling_grower(sprout_name), + sunlight_propagates = true, + walkable = false, + groups = sapling_groups, + on_construct = growth_timer + }) + minetest.register_node(sprout_name, { + description = S(data.description.." sprout"), + drawtype = "plantlike", + visual_scale = 1.4, + tiles = { modname.."_"..basename.."_sprout.png" }, + paramtype = "light", + sunlight_propagates = true, + walkable = false, + on_timer = ebiometrees.get_sprout_grower( + modname..":"..basename.."_trunk_growing_straight", + modname..":"..basename.."_trunk_growing_terminal"), + groups = sprout_groups, + on_construct = growth_timer + }) + -- registers tree and corresponding nodes + local trunk_groups = table.copy(data.groups) + trunk_groups.choppy = 2 -- TODO: customizations + local trunk_types = {"growing", "normal"} + local trunk_subtypes = {"terminal", "straight", "corner", + "tjunction", "t2junction", "xjunction", + "xtjunction", "x2junction"} + + for _, trunk_type in ipairs(trunk_types) + do + local texture_basename = modname.."_"..basename.."_trunk_"..trunk_type.."_" + local subtype_tiles = { + terminal = { + texture_basename.."terminal.png", + texture_basename.."slice.png", + texture_basename.."terminal.png" + }, + straight = { + texture_basename.."slice.png", + texture_basename.."slice.png", + texture_basename.."normal.png" + }, + corner = { + texture_basename.."normal.png", + texture_basename.."slice.png", + texture_basename.."corner.png^[transformFX", + texture_basename.."corner.png", + texture_basename.."normal.png", + texture_basename.."slice.png", + }, + tjunction = { + texture_basename.."slice.png", + texture_basename.."slice.png", + texture_basename.."tjunction.png^[transformFX", + texture_basename.."tjunction.png", + texture_basename.."normal.png", + texture_basename.."slice.png", + }, + t2junction = { + texture_basename.."slice.png", + texture_basename.."slice.png", + texture_basename.."tjunction.png^[transformFX", + texture_basename.."slice.png", + texture_basename.."tjunction.png", + texture_basename.."slice.png", + }, + xjunction = { + texture_basename.."slice.png", + texture_basename.."slice.png", + texture_basename.."xjunction.png^[transformFX", + texture_basename.."xjunction.png", + texture_basename.."slice.png", + texture_basename.."slice.png", + }, + xtjunction = { + texture_basename.."slice.png", + texture_basename.."slice.png", + texture_basename.."xjunction.png", + texture_basename.."slice.png", + texture_basename.."slice.png", + texture_basename.."slice.png", + }, + x2junction = { + texture_basename.."slice.png" + } + } + for _, trunk_subtype in ipairs(trunk_subtypes) + do + minetest.register_node( + modname..":"..basename.."_trunk_"..trunk_type.."_"..trunk_subtype, { + description = S(data.description.." "..trunk_type.." "..trunk_subtype), + groups = trunk_groups, + tiles = subtype_tiles[trunk_subtype], + paramtype2 = "facedir", + is_ground_content = false, + on_place = minetest.rotate_node, + on_timer = function(pos) + return true + end, + on_construct = growth_timer + }) + end + end +end +