trees now are now independent

master
yzelast 2017-01-05 15:04:33 -03:00
parent f07c5533da
commit 9681cada82
45 changed files with 2459 additions and 0 deletions

45
trees/acacia/abms.lua Normal file
View File

@ -0,0 +1,45 @@
minetest.register_abm {
nodenames = "default:acacia_sapling",
chance = 1,
interval = 2,
action = function(pos)
if acacia_growth(pos,1,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["acacia"] * 1)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_small_acacia_tree",
chance = 1,
interval = 4,
action = function(pos)
if acacia_growth(pos,2,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["acacia"] * 2)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_medium_acacia_tree",
chance = 1,
interval = 6,
action = function(pos)
if acacia_growth(pos,3,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["acacia"] * 3)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_large_acacia_tree",
chance = 1,
interval = 8,
action = function(pos)
if acacia_growth(pos,4,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["acacia"] * 4)
end
end
}

195
trees/acacia/functions.lua Normal file
View File

@ -0,0 +1,195 @@
local function node_exist(table,node)
for key,value in pairs(table) do
if value == node.name then
return true
end
end
return false
end
local function fix_trunks(pos,size)
if size == 1 then
for i = 0,1 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 2 then
for i = 0,2 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 3 then
for i = 0,2 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 4 then
for i = 0,2 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
end
end
local function fix_leaves(pos,radius)
local leaves = {
"real_trees:small_acacia_leaves",
"real_trees:corner_acacia_leaves",
"real_trees:wide_acacia_leaves",
"real_trees:acacia_leaf_slab",
"real_trees:corner_acacia_tree",
"real_trees:t_corner_acacia_tree",
"default:acacia_leaves"
}
if radius == 1 then
local positions = {
{x = pos.x - 1,y = pos.y,z = pos.z - 1},
{x = pos.x - 1,y = pos.y,z = pos.z},
{x = pos.x - 1,y = pos.y,z = pos.z + 1},
{x = pos.x,y = pos.y,z = pos.z - 1},
{x = pos.x,y = pos.y,z = pos.z + 1},
{x = pos.x + 1,y = pos.y,z = pos.z - 1},
{x = pos.x + 1,y = pos.y,z = pos.z},
{x = pos.x + 1,y = pos.y,z = pos.z + 1}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
elseif radius == 2 then
local positions = {
{x = pos.x - 2,y = pos.y,z = pos.z - 2},
{x = pos.x - 2,y = pos.y,z = pos.z - 1},
{x = pos.x - 2,y = pos.y,z = pos.z},
{x = pos.x - 2,y = pos.y,z = pos.z + 1},
{x = pos.x - 2,y = pos.y,z = pos.z + 2},
{x = pos.x - 1,y = pos.y,z = pos.z - 2},
{x = pos.x,y = pos.y,z = pos.z - 2},
{x = pos.x + 1,y = pos.y,z = pos.z - 2},
{x = pos.x - 1,y = pos.y,z = pos.z + 2},
{x = pos.x,y = pos.y,z = pos.z + 2},
{x = pos.x + 1,y = pos.y,z = pos.z + 2},
{x = pos.x + 2,y = pos.y,z = pos.z - 2},
{x = pos.x + 2,y = pos.y,z = pos.z - 1},
{x = pos.x + 2,y = pos.y,z = pos.z},
{x = pos.x + 2,y = pos.y,z = pos.z + 1},
{x = pos.x + 2,y = pos.y,z = pos.z + 2}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
elseif radius == 3 then
local positions = {
{x = pos.x - 3,y = pos.y,z = pos.z - 3},
{x = pos.x - 3,y = pos.y,z = pos.z - 2},
{x = pos.x - 3,y = pos.y,z = pos.z - 1},
{x = pos.x - 3,y = pos.y,z = pos.z},
{x = pos.x - 3,y = pos.y,z = pos.z + 1},
{x = pos.x - 3,y = pos.y,z = pos.z + 2},
{x = pos.x - 3,y = pos.y,z = pos.z + 3},
{x = pos.x - 2,y = pos.y,z = pos.z - 3},
{x = pos.x - 1,y = pos.y,z = pos.z - 3},
{x = pos.x,y = pos.y,z = pos.z - 3},
{x = pos.x + 1,y = pos.y,z = pos.z - 3},
{x = pos.x + 2,y = pos.y,z = pos.z - 3},
{x = pos.x - 2,y = pos.y,z = pos.z + 3},
{x = pos.x - 1,y = pos.y,z = pos.z + 3},
{x = pos.x,y = pos.y,z = pos.z + 3},
{x = pos.x + 1,y = pos.y,z = pos.z + 3},
{x = pos.x + 2,y = pos.y,z = pos.z + 3},
{x = pos.x + 3,y = pos.y,z = pos.z - 3},
{x = pos.x + 3,y = pos.y,z = pos.z - 2},
{x = pos.x + 3,y = pos.y,z = pos.z - 1},
{x = pos.x + 3,y = pos.y,z = pos.z},
{x = pos.x + 3,y = pos.y,z = pos.z + 1},
{x = pos.x + 3,y = pos.y,z = pos.z + 2},
{x = pos.x + 3,y = pos.y,z = pos.z + 3}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
end
end
local function fix_everything(pos,size)
if size == 1 then
fix_trunks(pos,1)
elseif size == 2 then
fix_trunks(pos,2)
fix_leaves({x = pos.x,y = pos.y + 1,z = pos.z},1)
elseif size == 3 then
fix_trunks(pos,3)
fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},2)
elseif size == 4 then
fix_trunks(pos,4)
fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},2)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},3)
fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},2)
fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},3)
end
end
local function can_grow(pos,size)
local soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_snow"}
local under = {x = pos.x,y = pos.y - 1,z = pos.z}
if size == 1 then
if minetest.get_node_light({x = pos.x,y = pos.y + 1,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 2 then
if minetest.get_node_light({x = pos.x,y = pos.y + 2,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 3 then
if minetest.get_node_light({x = pos.x,y = pos.y + 3,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 4 then
if minetest.get_node_light({x = pos.x,y = pos.y + 4,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
end
end
function acacia_growth(pos,size,action)
if action == 1 then
if can_grow(pos,size) then return true else return false end
elseif action == 2 then
if size == 1 then
fix_everything(pos,1)
minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/acacia/schems/small_acacia_tree.mts","0",nil,false)
elseif size == 2 then
fix_everything(pos,2)
minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/acacia/schems/medium_acacia_tree.mts","0",nil,false)
elseif size == 3 then
fix_everything(pos,3)
minetest.place_schematic({x = pos.x - 3,y = pos.y,z = pos.z - 3},minetest.get_modpath("real_trees").."/trees/acacia/schems/large_acacia_tree.mts","random",nil,false)
elseif size == 4 then
fix_everything(pos,4)
minetest.place_schematic({x = pos.x - 4,y = pos.y,z = pos.z - 4},minetest.get_modpath("real_trees").."/trees/acacia/schems/acacia_tree.mts","random",nil,false)
end
end
end

54
trees/acacia/itens.lua Normal file
View File

@ -0,0 +1,54 @@
minetest.register_craft({
type = "shapeless",
output = "default:acacia_wood 2",
recipe = {"real_trees:small_acacia_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:acacia_wood 4",
recipe = {"real_trees:medium_acacia_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:acacia_wood 6",
recipe = {"real_trees:large_acacia_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:acacia_wood 8",
recipe = {"default:acacia_tree"},
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:small_acacia_tree",
burntime = 8.5,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:medium_acacia_tree",
burntime = 17,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:large_acacia_tree",
burntime = 25.5,
})
minetest.override_item("default:acacia_sapling",{
on_timer = function(pos)
acacia_growth(pos,1,2)
end,
on_construct = function(pos)
if acacia_growth(pos,1,1) then
minetest.get_node_timer(pos):start(growth_time["acacia"] * 1)
end
end
})

79
trees/acacia/leaves.lua Normal file
View File

@ -0,0 +1,79 @@
minetest.register_node("real_trees:small_acacia_leaves", {
description = "Small Acacia Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:acacia_sapling"},rarity = 160},
{items = {"real_trees:small_acacia_leaves"}}
}
},
tiles = {"default_acacia_leaves.png"},
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}}
})
minetest.register_node("real_trees:corner_acacia_leaves", {
description = "Corner Acacia Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {'default:acacia_sapling'},rarity = 160},
{items = {'real_trees:corner_acacia_leaves'}}
}
},
tiles = { "default_acacia_leaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:wide_acacia_leaves", {
description = "Wide Acacia Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:acacia_sapling"},rarity = 80},
{items = {"real_trees:wide_acacia_leaves"}}
}
},
tiles = { "default_acacia_leaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.5,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:acacia_leaf_slab", {
description = "Acacia Leaf Slab",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:acacia_sapling"},rarity = 40},
{items = {"real_trees:acacia_leaf_slab"}}
}
},
tiles = { "default_acacia_leaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.5,-0.5,-0.5,0.5,0,0.5}}}
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

191
trees/acacia/trunks.lua Normal file
View File

@ -0,0 +1,191 @@
minetest.register_node("real_trees:corner_acacia_tree", {
description = "Corner Acacia Trunk",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_acacia_tree",
tiles = {
"real_trees_corner_acacia_tree_top.png",
"real_trees_corner_acacia_tree_top.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
},
node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:t_corner_acacia_tree", {
description = "T Corner Acacia Trunk",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_acacia_tree",
tiles = {
"real_trees_corner_acacia_tree_top.png",
"real_trees_corner_acacia_tree_top.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
},
node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0.5,0.5}}}
})
minetest.register_node("real_trees:small_acacia_tree", {
description = "Small Acacia Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_acacia_tree",
tiles = {
"real_trees_small_acacia_tree_top.png",
"real_trees_small_acacia_tree_top.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}}
})
minetest.register_node("real_trees:medium_acacia_tree", {
description = "Medium Acacia Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_acacia_tree",
tiles = {
"real_trees_medium_acacia_tree_top.png",
"real_trees_medium_acacia_tree_top.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}}
})
minetest.register_node("real_trees:large_acacia_tree", {
description = "Large Acacia Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_acacia_tree",
tiles = {
"real_trees_large_acacia_tree_top.png",
"real_trees_large_acacia_tree_top.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}}
})
minetest.register_node("real_trees:h_large_acacia_tree", {
description = "H Large Acacia Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_acacia_tree",
tiles = {
"default_acacia_tree_top.png",
"real_trees_large_acacia_tree_top.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
},
node_box = {type = "fixed",fixed = {
{-0.375,-0.5,0.375,0.375,0.5,-0.375},
{-0.5,0,-0.5,0.5,0.5,0.5}
}
}
})
minetest.register_node("real_trees:a_small_acacia_tree", {
description = "A Small Acacia Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_acacia_tree",
tiles = {
"real_trees_small_acacia_tree_top.png",
"real_trees_small_acacia_tree_top.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
},
node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}},
on_timer = function(pos,elapsed)
acacia_growth(pos,2,2)
end,
})
minetest.register_node("real_trees:a_medium_acacia_tree", {
description = "A Medium Acacia Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_acacia_tree",
tiles = {
"real_trees_medium_acacia_tree_top.png",
"real_trees_medium_acacia_tree_top.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
},
node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}},
on_timer = function(pos,elapsed)
acacia_growth(pos,3,2)
end,
})
minetest.register_node("real_trees:a_large_acacia_tree", {
description = "A Large Acacia Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_jungle_tree",
tiles = {
"real_trees_large_acacia_tree_top.png",
"real_trees_large_acacia_tree_top.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
"default_acacia_tree.png",
},
node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}},
on_timer = function(pos,elapsed)
acacia_growth(pos,4,2)
end,
})

43
trees/apple/abms.lua Normal file
View File

@ -0,0 +1,43 @@
minetest.register_abm {
nodenames = "default:sapling",
chance = 1,
interval = 2,
action = function(pos)
if apple_growth(pos,1,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["apple"] * 1)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_small_tree",
chance = 1,
interval = 4,
action = function(pos)
if apple_growth(pos,2,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["apple"] * 2)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_medium_tree",
chance = 1,
interval = 6,
action = function(pos)
if apple_growth(pos,3,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["apple"] * 3)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_large_tree",
chance = 1,
interval = 8,
action = function(pos)
if apple_growth(pos,4,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["apple"] * 4)
end
end
}

116
trees/apple/functions.lua Normal file
View File

@ -0,0 +1,116 @@
local function node_exist(table,node)
for key,value in pairs(table) do
if value == node.name then
return true
end
end
return false
end
local function fix_trunks(pos,size)
if size == 1 then
for i = 0,1 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 2 then
for i = 0,4 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 3 then
for i = 0,4 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 4 then
for i = 0,4 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
end
end
local function fix_leaves(pos)
local leaves = {
"real_trees:small_leaves",
"real_trees:corner_leaves",
"real_trees:wide_leaves",
"real_trees:leaf_slab",
"default:leaves",
}
local positions = {
{x = pos.x - 1,y = pos.y,z = pos.z - 1},
{x = pos.x - 1,y = pos.y,z = pos.z},
{x = pos.x - 1,y = pos.y,z = pos.z + 1},
{x = pos.x,y = pos.y,z = pos.z - 1},
{x = pos.x,y = pos.y,z = pos.z + 1},
{x = pos.x + 1,y = pos.y,z = pos.z - 1},
{x = pos.x + 1,y = pos.y,z = pos.z},
{x = pos.x + 1,y = pos.y,z = pos.z + 1}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
end
local function fix_everything(pos,size)
if size == 1 then
fix_trunks(pos,1)
elseif size == 2 then
fix_trunks(pos,2)
elseif size == 3 then
fix_trunks(pos,3)
fix_leaves({x = pos.x,y = pos.y + 1,z = pos.z})
fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z})
elseif size == 4 then
fix_trunks(pos,4)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z})
fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z})
end
end
local function can_grow(pos,size)
local soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_snow"}
local under = {x = pos.x,y = pos.y - 1,z = pos.z}
if size == 1 then
if minetest.get_node_light({x = pos.x,y = pos.y + 1,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 2 then
if minetest.get_node_light({x = pos.x,y = pos.y + 3,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 3 then
if minetest.get_node_light({x = pos.x,y = pos.y + 5,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 4 then
if minetest.get_node_light({x = pos.x,y = pos.y + 8,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
end
end
function apple_growth(pos,size,action)
if action == 1 then
if can_grow(pos,size) then return true else return false end
elseif action == 2 then
if size == 1 then
fix_everything(pos,1)
minetest.place_schematic(pos,minetest.get_modpath("real_trees").."/trees/apple/schems/small_tree.mts","0",nil,false)
elseif size == 2 then
fix_everything(pos,2)
minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/apple/schems/medium_tree.mts","0",nil,false)
elseif size == 3 then
fix_everything(pos,3)
minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/apple/schems/large_tree.mts","0",nil,false)
elseif size == 4 then
fix_everything(pos,4)
minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/apple/schems/tree.mts","random",nil,false)
end
end
end

53
trees/apple/itens.lua Normal file
View File

@ -0,0 +1,53 @@
minetest.register_craft({
type = "shapeless",
output = "default:wood 2",
recipe = {"real_trees:small_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:wood 4",
recipe = {"real_trees:medium_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:wood 6",
recipe = {"real_trees:large_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:wood 8",
recipe = {"default:tree"},
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:small_tree",
burntime = 7.5,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:medium_tree",
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:large_tree",
burntime = 22.5,
})
minetest.override_item("default:sapling",{
on_timer = function(pos)
apple_growth(pos,1,2)
end,
on_construct = function(pos)
if apple_growth(pos,1,1) then
minetest.get_node_timer(pos):start(growth_time["apple"] * 1)
end
end
})

79
trees/apple/leaves.lua Normal file
View File

@ -0,0 +1,79 @@
minetest.register_node("real_trees:small_leaves", {
description = "Small Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:sapling"},rarity = 160},
{items = {'real_trees:small_leaves'}}
}
},
tiles = {"default_leaves.png"},
after_place_node = default.after_place_leaves,
node_box = {type = "fixed", fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}}
})
minetest.register_node("real_trees:corner_leaves", {
description = "Corner Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:sapling"},rarity = 160},
items = {"real_trees:corner_leaves"}
}
},
tiles = {"default_leaves.png"},
after_place_node = default.after_place_leaves,
node_box = {type = "fixed", fixed = {{0,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:wide_leaves", {
description = "Wide Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:sapling"},rarity = 80},
{items = {"real_trees:wide_leaves"}}
}
},
tiles = {"default_leaves.png"},
after_place_node = default.after_place_leaves,
node_box = {type = "fixed", fixed = {{-0.5,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:leaf_slab", {
description = "Leaf Slab",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:sapling"},rarity = 40},
{items = {"real_trees:pine_needle_slab"}}
}
},
tiles = {"default_leaves.png"},
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.5,-0.5,-0.5,0.5,0,0.5}}}
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
trees/apple/schems/tree.mts Normal file

Binary file not shown.

128
trees/apple/trunks.lua Normal file
View File

@ -0,0 +1,128 @@
minetest.register_node("real_trees:small_tree", {
description = "Small Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_tree",
tiles = {
"real_trees_small_tree_top.png",
"real_trees_small_tree_top.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed", fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}}
})
minetest.register_node("real_trees:medium_tree", {
description = "Medium Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_tree",
tiles = {
"real_trees_medium_tree_top.png",
"real_trees_medium_tree_top.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed", fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}}
})
minetest.register_node("real_trees:large_tree", {
description = "Large Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_tree",
tiles = {
"real_trees_large_tree_top.png",
"real_trees_large_tree_top.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed", fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}}
})
minetest.register_node("real_trees:a_small_tree", {
description = "A Small Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_tree",
tiles = {
"real_trees_small_tree_top.png",
"real_trees_small_tree_top.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
},
node_box = {type = "fixed", fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}},
on_timer = function(pos,elapsed)
apple_growth(pos,2,2)
end
})
minetest.register_node("real_trees:a_medium_tree", {
description = "A Medium Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_tree",
tiles = {
"real_trees_medium_tree_top.png",
"real_trees_medium_tree_top.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
},
node_box = {type = "fixed", fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}},
on_timer = function(pos,elapsed)
apple_growth(pos,3,2)
end
})
minetest.register_node("real_trees:a_large_tree", {
description = "A Large Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_tree",
tiles = {
"real_trees_large_tree_top.png",
"real_trees_large_tree_top.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
"default_tree.png",
},
node_box = {type = "fixed", fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}},
on_timer = function(pos,elapsed)
apple_growth(pos,4,2)
end
})

45
trees/aspen/abms.lua Normal file
View File

@ -0,0 +1,45 @@
minetest.register_abm {
nodenames = "default:aspen_sapling",
chance = 1,
interval = 2,
action = function(pos)
if aspen_growth(pos,1,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["aspen"] * 1)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_small_aspen_tree",
chance = 1,
interval = 4,
action = function(pos)
if aspen_growth(pos,2,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["aspen"] * 2)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_medium_aspen_tree",
chance = 1,
interval = 6,
action = function(pos)
if aspen_growth(pos,3,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["aspen"] * 3)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_large_aspen_tree",
chance = 1,
interval = 8,
action = function(pos)
if aspen_growth(pos,4,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["aspen"] * 4)
end
end
}

155
trees/aspen/functions.lua Normal file
View File

@ -0,0 +1,155 @@
local function node_exist(table,node)
for key,value in pairs(table) do
if value == node.name then
return true
end
end
return false
end
local function fix_trunks(pos,size)
if size == 1 then
for i = 0,1 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 2 then
for i = 0,2 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 3 then
for i = 0,5 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 4 then
for i = 0,7 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
end
end
local function fix_leaves(pos,radius)
local leaves = {
"real_trees:small_aspen_leaves",
"real_trees:u_small_aspen_leaves",
"real_trees:corner_aspen_leaves",
"real_trees:wide_aspen_leaves",
"real_trees:aspen_leaf_slab",
"default:aspen_leaves"
}
if radius == 1 then
local positions = {
{x = pos.x - 1,y = pos.y,z = pos.z - 1},
{x = pos.x - 1,y = pos.y,z = pos.z},
{x = pos.x - 1,y = pos.y,z = pos.z + 1},
{x = pos.x,y = pos.y,z = pos.z - 1},
{x = pos.x,y = pos.y,z = pos.z + 1},
{x = pos.x + 1,y = pos.y,z = pos.z - 1},
{x = pos.x + 1,y = pos.y,z = pos.z},
{x = pos.x + 1,y = pos.y,z = pos.z + 1}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
elseif radius == 2 then
local positions = {
{x = pos.x - 2,y = pos.y,z = pos.z - 2},
{x = pos.x - 2,y = pos.y,z = pos.z - 1},
{x = pos.x - 2,y = pos.y,z = pos.z},
{x = pos.x - 2,y = pos.y,z = pos.z + 1},
{x = pos.x - 2,y = pos.y,z = pos.z + 2},
{x = pos.x - 1,y = pos.y,z = pos.z - 2},
{x = pos.x,y = pos.y,z = pos.z - 2},
{x = pos.x + 1,y = pos.y,z = pos.z - 2},
{x = pos.x - 1,y = pos.y,z = pos.z + 2},
{x = pos.x,y = pos.y,z = pos.z + 2},
{x = pos.x + 1,y = pos.y,z = pos.z + 2},
{x = pos.x + 2,y = pos.y,z = pos.z - 2},
{x = pos.x + 2,y = pos.y,z = pos.z - 1},
{x = pos.x + 2,y = pos.y,z = pos.z},
{x = pos.x + 2,y = pos.y,z = pos.z + 1},
{x = pos.x + 2,y = pos.y,z = pos.z + 2}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
end
end
local function fix_everything(pos,size)
if size == 1 then
fix_trunks(pos,1)
elseif size == 2 then
fix_trunks(pos,2)
fix_leaves({x = pos.x,y = pos.y + 1,z = pos.z},1)
elseif size == 3 then
fix_trunks(pos,3)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},1)
elseif size == 4 then
fix_trunks(pos,4)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 6,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 7,z = pos.z},1)
end
end
local function can_grow(pos,size)
local soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_snow"}
local under = {x = pos.x,y = pos.y - 1,z = pos.z}
if size == 1 then
if minetest.get_node_light({x = pos.x,y = pos.y + 1,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 2 then
if minetest.get_node_light({x = pos.x,y = pos.y + 3,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 3 then
if minetest.get_node_light({x = pos.x,y = pos.y + 6,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 4 then
if minetest.get_node_light({x = pos.x,y = pos.y + 8,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
end
end
function aspen_growth(pos,size,action)
if action == 1 then
if can_grow(pos,size) then return true else return false end
elseif action == 2 then
if size == 1 then
fix_everything(pos,1)
minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/aspen/schems/small_aspen_tree.mts","0",nil,false)
elseif size == 2 then
fix_everything(pos,2)
minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/aspen/schems/medium_aspen_tree.mts","0",nil,false)
elseif size == 3 then
fix_everything(pos,3)
minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/aspen/schems/large_aspen_tree.mts","0",nil,false)
elseif size == 4 then
fix_everything(pos,4)
minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/aspen/schems/aspen_tree.mts","0",nil,false)
end
end
end

54
trees/aspen/itens.lua Normal file
View File

@ -0,0 +1,54 @@
minetest.register_craft({
type = "shapeless",
output = "default:aspen_wood 2",
recipe = {"real_trees:small_aspen_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:aspen_wood 4",
recipe = {"real_trees:medium_aspen_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:aspen_wood 6",
recipe = {"real_trees:large_aspen_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:aspen_wood 8",
recipe = {"default:aspen_tree"},
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:small_aspen_tree",
burntime = 5.5,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:medium_aspen_tree",
burntime = 11,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:large_aspen_tree",
burntime = 16.5,
})
minetest.override_item("default:aspen_sapling",{
on_timer = function(pos)
aspen_growth(pos,1,2)
end,
on_construct = function(pos)
if aspen_growth(pos,1,1) then
minetest.get_node_timer(pos):start(growth_time["aspen"] * 1)
end
end,
})

79
trees/aspen/leaves.lua Normal file
View File

@ -0,0 +1,79 @@
minetest.register_node("real_trees:small_aspen_leaves", {
description = "Small Aspen Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:aspen_sapling"},rarity = 160},
{items = {"real_trees:small_aspen_leaves"}}
}
},
tiles = { "default_aspen_leaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}}
})
minetest.register_node("real_trees:corner_aspen_leaves", {
description = "Corner Aspen Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:aspen_sapling"},rarity = 160},
{items = {"real_trees:corner_aspen_leaves"}}
}
},
tiles = { "default_aspen_leaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:wide_aspen_leaves", {
description = "Wide Aspen Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:aspen_sapling"},rarity = 80},
{items = {"real_trees:wide_aspen_leaves"}}
}
},
tiles = { "default_aspen_leaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.5,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:aspen_leaf_slab", {
description = "Aspen Leaf Slab",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:aspen_sapling"},rarity = 40},
{items = {"real_trees:aspen_leaf_slab"}}
}
},
tiles = { "default_aspen_leaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.5,-0.5,-0.5,0.5,0,0.5}}}
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

131
trees/aspen/trunks.lua Normal file
View File

@ -0,0 +1,131 @@
minetest.register_node("real_trees:small_aspen_tree", {
description = "Small Aspen Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_aspen_tree",
tiles = {
"real_trees_small_aspen_tree_top.png",
"real_trees_small_aspen_tree_top.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}}
})
minetest.register_node("real_trees:medium_aspen_tree", {
description = "Medium Aspen Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_aspen_tree",
tiles = {
"real_trees_medium_aspen_tree_top.png",
"real_trees_medium_aspen_tree_top.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}}
})
minetest.register_node("real_trees:large_aspen_tree", {
description = "Large Aspen Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_aspen_tree",
tiles = {
"real_trees_large_aspen_tree_top.png",
"real_trees_large_aspen_tree_top.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}}
})
minetest.register_node("real_trees:a_small_aspen_tree", {
description = "A Small Aspen Tree",
drawtype = "nodebox",
paramtype = "light",
drop = "real_trees:small_aspen_tree",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
tiles = {
"real_trees_small_aspen_tree_top.png",
"real_trees_small_aspen_tree_top.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
},
on_timer = function(pos,elapsed)
aspen_growth(pos,2,2)
end,
node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}}
})
minetest.register_node("real_trees:a_medium_aspen_tree", {
description = "A Medium Aspen Tree",
drawtype = "nodebox",
paramtype = "light",
drop = "real_trees:medium_aspen_tree",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
tiles = {
"real_trees_medium_aspen_tree_top.png",
"real_trees_medium_aspen_tree_top.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
},
on_timer = function(pos,elapsed)
aspen_growth(pos,3,2)
end,
node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}}
})
minetest.register_node("real_trees:a_large_aspen_tree", {
description = "A Large Aspen Tree",
drawtype = "nodebox",
paramtype = "light",
drop = "real_trees:large_aspen_tree",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
tiles = {
"real_trees_large_aspen_tree_top.png",
"real_trees_large_aspen_tree_top.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
"default_aspen_tree.png",
},
on_timer = function(pos,elapsed)
aspen_growth(pos,4,2)
end,
node_box = {type = "fixed",fixed = { {-0.375,-0.5,0.375,0.375,0.5,-0.375}}}
})

43
trees/jungle/abms.lua Normal file
View File

@ -0,0 +1,43 @@
minetest.register_abm {
nodenames = "default:junglesapling",
chance = 1,
interval = 2,
action = function(pos)
if jungle_growth(pos,1,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["jungle"] * 1)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_small_jungle_tree",
chance = 1,
interval = 4,
action = function(pos)
if jungle_growth(pos,2,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["jungle"] * 2)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_medium_jungle_tree",
chance = 1,
interval = 6,
action = function(pos)
if jungle_growth(pos,3,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["jungle"] * 3)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_large_jungle_tree",
chance = 1,
interval = 8,
action = function(pos)
if jungle_growth(pos,4,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["jungle"] * 4)
end
end
}

160
trees/jungle/functions.lua Normal file
View File

@ -0,0 +1,160 @@
local function node_exist(table,node)
for key,value in pairs(table) do
if value == node.name then
return true
end
end
return false
end
local function fix_trunks(pos,size)
if size == 1 then
for i = 0,1 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 2 then
for i = 0,4 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 3 then
for i = 0,7 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 4 then
for i = 0,11 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
end
end
local function fix_leaves(pos,radius)
local leaves = {
"real_trees:small_jungle_leaves",
"real_trees:corner_jungle_leaves",
"real_trees:wide_jungle_leaves",
"real_trees:jungle_leaf_slab",
"real_trees:medium_jungle_tree",
"real_trees:large_jungle_tree",
"default:jungleleaves",
}
if radius == 1 then
local positions = {
{x = pos.x - 1,y = pos.y,z = pos.z - 1},
{x = pos.x - 1,y = pos.y,z = pos.z},
{x = pos.x - 1,y = pos.y,z = pos.z + 1},
{x = pos.x,y = pos.y,z = pos.z - 1},
{x = pos.x,y = pos.y,z = pos.z + 1},
{x = pos.x + 1,y = pos.y,z = pos.z - 1},
{x = pos.x + 1,y = pos.y,z = pos.z},
{x = pos.x + 1,y = pos.y,z = pos.z + 1}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
elseif radius == 2 then
local positions = {
{x = pos.x - 2,y = pos.y,z = pos.z - 2},
{x = pos.x - 2,y = pos.y,z = pos.z - 1},
{x = pos.x - 2,y = pos.y,z = pos.z},
{x = pos.x - 2,y = pos.y,z = pos.z + 1},
{x = pos.x - 2,y = pos.y,z = pos.z + 2},
{x = pos.x - 1,y = pos.y,z = pos.z - 2},
{x = pos.x,y = pos.y,z = pos.z - 2},
{x = pos.x + 1,y = pos.y,z = pos.z - 2},
{x = pos.x - 1,y = pos.y,z = pos.z + 2},
{x = pos.x,y = pos.y,z = pos.z + 2},
{x = pos.x + 1,y = pos.y,z = pos.z + 2},
{x = pos.x + 2,y = pos.y,z = pos.z - 2},
{x = pos.x + 2,y = pos.y,z = pos.z - 1},
{x = pos.x + 2,y = pos.y,z = pos.z},
{x = pos.x + 2,y = pos.y,z = pos.z + 1},
{x = pos.x + 2,y = pos.y,z = pos.z + 2}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
end
end
local function fix_everything(pos,size)
if size == 1 then
fix_trunks(pos,1)
elseif size == 2 then
fix_trunks(pos,2)
fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},1)
elseif size == 3 then
fix_trunks(pos,3)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},2)
fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},2)
fix_leaves({x = pos.x,y = pos.y + 7,z = pos.z},1)
elseif size == 4 then
fix_trunks(pos,4)
fix_leaves({x = pos.x,y = pos.y,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 1,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},2)
fix_leaves({x = pos.x,y = pos.y + 7,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 7,z = pos.z},2)
fix_leaves({x = pos.x,y = pos.y + 10,z = pos.z},1)
end
end
local function can_grow(pos,size)
local soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_snow"}
local under = {x = pos.x,y = pos.y - 1,z = pos.z}
if size == 1 then
if minetest.get_node_light({x = pos.x,y = pos.y + 1,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 2 then
if minetest.get_node_light({x = pos.x,y = pos.y + 5,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 3 then
if minetest.get_node_light({x = pos.x,y = pos.y + 8,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 4 then
if minetest.get_node_light({x = pos.x,y = pos.y + 12,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
end
end
function jungle_growth(pos,size,action)
if action == 1 then
if can_grow(pos,size) then return true else return false end
elseif action == 2 then
if size == 1 then
fix_everything(pos,1)
minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/jungle/schems/small_jungle_tree.mts","0",nil,false)
elseif size == 2 then
fix_everything(pos,2)
minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/jungle/schems/medium_jungle_tree.mts","random",nil,false)
elseif size == 3 then
fix_everything(pos,3)
minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/jungle/schems/large_jungle_tree.mts","random",nil,false)
elseif size == 4 then
fix_everything(pos,4)
minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/jungle/schems/jungle_tree.mts","random",nil,false)
end
end
end

64
trees/jungle/itens.lua Normal file
View File

@ -0,0 +1,64 @@
minetest.register_craft({
type = "shapeless",
output = "default:junglewood 2",
recipe = {"real_trees:small_jungle_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:junglewood 4",
recipe = {"real_trees:medium_jungle_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:junglewood 6",
recipe = {"real_trees:large_jungle_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:junglewood 8",
recipe = {"default:jungletree"},
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:small_jungle_tree",
burntime = 9.5,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:medium_jungle_tree",
burntime = 19,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:large_jungle_tree",
burntime = 28.5,
})
minetest.override_item("default:junglesapling",{
on_timer = function(pos)
jungle_growth(pos,1,2)
end,
on_construct = function(pos)
if jungle_growth(pos,1,1) then
minetest.get_node_timer(pos):start(growth_time["jungle"] * 1)
end
end,
})
minetest.override_item("default:jungletree",{
tiles = {
"real_trees_alt_jungle_tree_top.png",
"real_trees_alt_jungle_tree_top.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
},
})

79
trees/jungle/leaves.lua Normal file
View File

@ -0,0 +1,79 @@
minetest.register_node("real_trees:small_jungle_leaves", {
description = "Small Jungle Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:jungle_sapling"},rarity = 160},
{items = {"real_trees:small_leaves"}}
}
},
tiles = { "default_jungleleaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}}
})
minetest.register_node("real_trees:corner_jungle_leaves", {
description = "Corner Jungle Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:jungle_sapling"},rarity = 160},
{items = {"real_trees:corner_jungle_leaves"}}
}
},
tiles = { "default_jungleleaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:wide_jungle_leaves", {
description = "Wide Jungle Leaves",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:jungle_sapling"},rarity = 80},
{items = {"real_trees:wide_jungle_leaves"}}
}
},
tiles = { "default_jungleleaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.5,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:jungle_leaf_slab", {
description = "Jungle Leaf Slab",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:jungle_sapling"},rarity = 40},
{items = {"real_trees:jungle_leaf_slab"}}
}
},
tiles = { "default_jungleleaves.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.5,-0.5,-0.5,0.5,0,0.5}}}
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

128
trees/jungle/trunks.lua Normal file
View File

@ -0,0 +1,128 @@
minetest.register_node("real_trees:small_jungle_tree", {
description = "Small Jungle Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_jungle_tree",
tiles = {
"real_trees_small_jungle_tree_top.png",
"real_trees_small_jungle_tree_top.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}}
})
minetest.register_node("real_trees:medium_jungle_tree", {
description = "Medium Jungle Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_jungle_tree",
tiles = {
"real_trees_medium_jungle_tree_top.png",
"real_trees_medium_jungle_tree_top.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}}
})
minetest.register_node("real_trees:large_jungle_tree", {
description = "Large Jungle Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_jungle_tree",
tiles = {
"real_trees_large_jungle_tree_top.png",
"real_trees_large_jungle_tree_top.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}}
})
minetest.register_node("real_trees:a_small_jungle_tree", {
description = "A Small Jungle Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_jungle_tree",
tiles = {
"real_trees_small_jungle_tree_top.png",
"real_trees_small_jungle_tree_top.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
},
node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}},
on_timer = function(pos,elapsed)
jungle_growth(pos,2,2)
end
})
minetest.register_node("real_trees:a_medium_jungle_tree", {
description = "A Medium Jungle Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_jungle_tree",
tiles = {
"real_trees_medium_jungle_tree_top.png",
"real_trees_medium_jungle_tree_top.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
},
node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}},
on_timer = function(pos,elapsed)
jungle_growth(pos,3,2)
end,
})
minetest.register_node("real_trees:a_large_jungle_tree", {
description = "A Large Jungle Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_jungle_tree",
tiles = {
"real_trees_large_jungle_tree_top.png",
"real_trees_large_jungle_tree_top.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
"default_jungletree.png",
},
node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}},
on_timer = function(pos,elapsed)
jungle_growth(pos,4,2)
end
})

43
trees/pine/abms.lua Normal file
View File

@ -0,0 +1,43 @@
minetest.register_abm {
nodenames = "default:pine_sapling",
chance = 1,
interval = 2,
action = function(pos)
if pine_growth(pos,1,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["pine"] * 1)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_small_pine_tree",
chance = 1,
interval = 4,
action = function(pos)
if pine_growth(pos,2,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["pine"] * 2)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_medium_pine_tree",
chance = 1,
interval = 6,
action = function(pos)
if pine_growth(pos,3,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["pine"] * 3)
end
end
}
minetest.register_abm {
nodenames = "real_trees:a_large_pine_tree",
chance = 1,
interval = 8,
action = function(pos)
if pine_growth(pos,4,1) and (not minetest.get_node_timer(pos):is_started()) then
minetest.get_node_timer(pos):start(growth_time["pine"] * 4)
end
end
}

160
trees/pine/functions.lua Normal file
View File

@ -0,0 +1,160 @@
local function node_exist(table,node)
for key,value in pairs(table) do
if value == node.name then
return true
end
end
return false
end
local function fix_trunks(pos,size)
if size == 1 then
for i = 0,1 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 2 then
for i = 0,4 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 3 then
for i = 0,6 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
elseif size == 4 then
for i = 0,10 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end
end
end
local function fix_leaves(pos,radius)
local leaves = {
"real_trees:small_pine_needles",
"real_trees:corner_pine_needles",
"real_trees:m_corner_pine_needles",
"real_trees:wide_pine_needles",
"real_trees:m_wide_pine_needles",
"real_trees:pine_needle_slab",
"real_trees:b_pine_needle_slab",
"real_trees:m_pine_needle_slab",
"default:pine_needles"
}
if radius == 1 then
local positions = {
{x = pos.x - 1,y = pos.y,z = pos.z - 1},
{x = pos.x - 1,y = pos.y,z = pos.z},
{x = pos.x - 1,y = pos.y,z = pos.z + 1},
{x = pos.x,y = pos.y,z = pos.z - 1},
{x = pos.x,y = pos.y,z = pos.z + 1},
{x = pos.x + 1,y = pos.y,z = pos.z - 1},
{x = pos.x + 1,y = pos.y,z = pos.z},
{x = pos.x + 1,y = pos.y,z = pos.z + 1}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
elseif radius == 2 then
local positions = {
{x = pos.x - 2,y = pos.y,z = pos.z - 2},
{x = pos.x - 2,y = pos.y,z = pos.z - 1},
{x = pos.x - 2,y = pos.y,z = pos.z},
{x = pos.x - 2,y = pos.y,z = pos.z + 1},
{x = pos.x - 2,y = pos.y,z = pos.z + 2},
{x = pos.x - 1,y = pos.y,z = pos.z - 2},
{x = pos.x,y = pos.y,z = pos.z - 2},
{x = pos.x + 1,y = pos.y,z = pos.z - 2},
{x = pos.x - 1,y = pos.y,z = pos.z + 2},
{x = pos.x,y = pos.y,z = pos.z + 2},
{x = pos.x + 1,y = pos.y,z = pos.z + 2},
{x = pos.x + 2,y = pos.y,z = pos.z - 2},
{x = pos.x + 2,y = pos.y,z = pos.z - 1},
{x = pos.x + 2,y = pos.y,z = pos.z},
{x = pos.x + 2,y = pos.y,z = pos.z + 1},
{x = pos.x + 2,y = pos.y,z = pos.z + 2}
}
for key,value in pairs(positions) do
if node_exist(leaves,minetest.get_node(value)) then
minetest.set_node(value,{name = "air"})
end
end
end
end
local function fix_everything(pos,size)
if size == 1 then
fix_trunks(pos,1)
elseif size == 2 then
fix_trunks(pos,2)
fix_leaves({x = pos.x,y = pos.y + 1,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},1)
elseif size == 3 then
fix_trunks(pos,3)
fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},1)
elseif size == 4 then
fix_trunks(pos,4)
fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},2)
fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},1)
fix_leaves({x = pos.x,y = pos.y + 6,z = pos.z},1)
end
end
local function can_grow(pos,size)
local soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_snow"}
local under = {x = pos.x,y = pos.y - 1,z = pos.z}
if size == 1 then
if minetest.get_node_light({x = pos.x,y = pos.y + 1,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 2 then
if minetest.get_node_light({x = pos.x,y = pos.y + 4,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 3 then
if minetest.get_node_light({x = pos.x,y = pos.y + 6,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
elseif size == 4 then
if minetest.get_node_light({x = pos.x,y = pos.y + 8,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then
return true
else
return false
end
end
end
function pine_growth(pos,size,action)
if action == 1 then
if can_grow(pos,size) then return true else return false end
elseif action == 2 then
if size == 1 then
fix_everything(pos,1)
minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/pine/schems/small_pine_tree.mts","0",nil,false)
elseif size == 2 then
fix_everything(pos,2)
minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/pine/schems/medium_pine_tree.mts","0",nil,false)
elseif size == 3 then
fix_everything(pos,3)
minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/pine/schems/large_pine_tree.mts","0",nil,false)
elseif size == 4 then
fix_everything(pos,4)
minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/pine/schems/pine_tree.mts","0",nil,false)
end
end
end

53
trees/pine/itens.lua Normal file
View File

@ -0,0 +1,53 @@
minetest.register_craft({
type = "shapeless",
output = "default:pine_wood 2",
recipe = {"real_trees:small_pine_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:pine_wood 4",
recipe = {"real_trees:medium_pine_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:pine_wood 6",
recipe = {"real_trees:large_pine_tree"},
})
minetest.register_craft({
type = "shapeless",
output = "default:pine_wood 8",
recipe = {"default:pine_tree"},
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:small_pine_tree",
burntime = 5.5,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:medium_pine_tree",
burntime = 13,
})
minetest.register_craft({
type = "fuel",
recipe = "real_trees:large_pine_tree",
burntime = 19.5,
})
minetest.override_item("default:pine_sapling",{
on_timer = function(pos)
pine_growth(pos,1,2)
end,
on_construct = function(pos)
if pine_growth(pos,1,1) then
minetest.get_node_timer(pos):start(growth_time["pine"] * 1)
end
end,
})

154
trees/pine/leaves.lua Normal file
View File

@ -0,0 +1,154 @@
minetest.register_node("real_trees:small_pine_needles", {
description = "Small Pine Needles",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:pine_sapling"},rarity = 60},
{items = {"real_trees:small_pine_needles"}}
}
},
tiles = {"default_pine_needles.png"},
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}}
})
minetest.register_node("real_trees:corner_pine_needles", {
description = "Corner Pine Needles",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:pine_sapling"},rarity = 40},
{items = {"real_trees:corner_pine_needles"}}
}
},
tiles = {"default_pine_needles.png"},
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0,0.5}}}
})
minetest.register_node("real_trees:m_corner_pine_needles", {
description = "M Corner Pine Needles",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:pine_sapling"},rarity = 40},
{items = {"real_trees:corner_pine_needles"}}
}
},
tiles = {"default_pine_needles.png"},
node_box = {type = "fixed",fixed = {{0,-0.25,0,0.5,0.25,0.5}}}
})
minetest.register_node("real_trees:wide_pine_needles", {
description = "Wide Pine Needles",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
drop = {
max_items = 1,
items = {
{items = {"default:pine_sapling"},rarity = 40},
{items = {"real_trees:wide_pine_needles"}}
}
},
tiles = {"default_pine_needles.png"},
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.5,-0.5,0,0.5,0,0.5}}},
})
minetest.register_node("real_trees:m_wide_pine_needles", {
description = "M Wide Pine Needles",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:pine_sapling"},rarity = 40},
{items = {"real_trees:wide_pine_needles"}}
}
},
tiles = {"default_pine_needles.png"},
node_box = {type = "fixed",fixed = {{-0.5,-0.25,0,0.5,0.25,0.5}}}
})
minetest.register_node("real_trees:pine_needle_slab", {
description = "Pine Needle Slab",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:pine_sapling"},rarity = 60},
{items = {"real_trees:pine_needle_slab"}}
}
},
tiles = { "default_pine_needles.png" },
after_place_node = default.after_place_leaves,
node_box = {type = "fixed",fixed = {{-0.5,-0.5,-0.5,0.5,0,0.5}}}
})
minetest.register_node("real_trees:b_pine_needle_slab", {
description = " B Pine Needle Slab",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:pine_sapling"},rarity = 60},
{items = {"real_trees:pine_needle_slab"}}
}
},
tiles = { "default_pine_needles.png" },
node_box = {type = "fixed",fixed = {{-0.5,-0.75,-0.5,0.5,-0.25,0.5}}}
})
minetest.register_node("real_trees:m_pine_needle_slab", {
description = "M Pine Needle Slab",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"default:pine_sapling"},rarity = 60},
{items = {"real_trees:pine_needle_slab"}}
}
},
tiles = { "default_pine_needles.png" },
node_box = {type = "fixed",fixed = {{-0.5,-0.25,-0.5,0.5,0.25,0.5}}}
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

128
trees/pine/trunks.lua Normal file
View File

@ -0,0 +1,128 @@
minetest.register_node("real_trees:small_pine_tree", {
description = "Small Pine Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_pine_tree",
tiles = {
"real_trees_small_pine_tree_top.png",
"real_trees_small_pine_tree_top.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}}
})
minetest.register_node("real_trees:medium_pine_tree", {
description = "Medium Pine Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_pine_tree",
tiles = {
"real_trees_medium_pine_tree_top.png",
"real_trees_medium_pine_tree_top.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}}
})
minetest.register_node("real_trees:large_pine_tree", {
description = "Large Pine Tree",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_pine_tree",
tiles = {
"real_trees_large_pine_tree_top.png",
"real_trees_large_pine_tree_top.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
},
on_place = minetest.rotate_node,
node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}}
})
minetest.register_node("real_trees:a_small_pine_tree", {
description = "A Small Pine Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:small_pine_tree",
tiles = {
"real_trees_small_pine_tree_top.png",
"real_trees_small_pine_tree_top.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
},
node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}},
on_timer = function(pos)
pine_growth(pos,2,2)
end
})
minetest.register_node("real_trees:a_medium_pine_tree", {
description = "A Medium Pine Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:medium_pine_tree",
tiles = {
"real_trees_medium_pine_tree_top.png",
"real_trees_medium_pine_tree_top.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
},
node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}},
on_timer = function(pos)
pine_growth(pos,3,2)
end
})
minetest.register_node("real_trees:a_large_pine_tree", {
description = "A Large Pine Tree",
drawtype = "nodebox",
paramtype = "light",
groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
drop = "real_trees:large_pine_tree",
tiles = {
"real_trees_large_pine_tree_top.png",
"real_trees_large_pine_tree_top.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
"default_pine_tree.png",
},
node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}},
on_timer = function(pos)
pine_growth(pos,4,2)
end,
})