add christmas tree

This commit is contained in:
Juraj Vajda 2018-12-03 23:42:22 -05:00
parent 5d65449c13
commit ce8c596ceb
12 changed files with 175 additions and 5 deletions

View File

@ -109,3 +109,12 @@ minetest.register_craft({
output = "default:bronze_ingot",
recipe = {"default:steel_ingot", "default:copper_ingot"},
})
minetest.register_craft({
output = "x_default:christmas_tree_sapling",
recipe = {
{"default:goldblock", "default:meselamp", "default:goldblock"},
{"wool:green", "default:pine_sapling", "wool:blue"},
{"wool:yellow", "default:pine_sapling", "wool:red"}
}
})

View File

@ -9,17 +9,18 @@ x_default.storage = minetest.get_mod_storage()
-- Load files
local default_path = minetest.get_modpath("x_default")
dofile(default_path.."/mapgen.lua")
dofile(default_path.."/functions.lua")
dofile(default_path.."/trees.lua")
dofile(default_path.."/nodes.lua")
dofile(default_path.."/tools.lua")
dofile(default_path.."/treasure_chest_list.lua")
dofile(default_path.."/chests.lua")
dofile(default_path.."/tools.lua")
dofile(default_path.."/pvp.lua")
dofile(default_path.."/item_drop.lua")
-- dofile(default_path.."/clean_unknown.lua")
dofile(default_path.."/craftitems.lua")
dofile(default_path.."/crafting.lua")
dofile(default_path.."/pvp.lua")
dofile(default_path.."/item_drop.lua")
dofile(default_path.."/chatcommands.lua")
dofile(default_path.."/mapgen.lua")
-- dofile(default_path.."/clean_unknown.lua")
x_default:sync_treasure_chests_storage()

View File

@ -179,3 +179,89 @@ minetest.register_node("x_default:stone_with_lapis", {
drop = 'x_default:lapis_lump',
sounds = default.node_sound_stone_defaults(),
})
--
-- Christmas Tree
--
minetest.register_node("x_default:christmas_tree_sapling", {
description = "Christmas Tree Sapling",
drawtype = "plantlike",
tiles = { "x_default_christmas_tree_sapling.png" },
inventory_image = "x_default_christmas_tree_sapling.png",
wield_image = "x_default_christmas_tree_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
on_timer = x_default.grow_sapling,
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
groups = {snappy = 2, dig_immediate = 3, flammable = 3,
attached_node = 1, sapling = 1},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
on_place = function(itemstack, placer, pointed_thing)
itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
"x_default:christmas_tree_sapling",
-- minp, maxp to be checked, relative to sapling pos
-- minp_relative.y = 1 because sapling pos has been checked
{x = -2, y = 1, z = -2},
{x = 2, y = 14, z = 2},
-- maximum interval of interior volume check
4)
return itemstack
end,
})
-- Decorated Pine Leaves
minetest.register_node("x_default:christmas_tree_needles", {
description ="Decorated Pine Needles",
drawtype = "allfaces_optional",
tiles = {
{
-- Animated, "blinking lights" version. ~ LazyJ
name = "x_default_pine_needles_decorated_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 20.0
},
}
},
waving = 0,
paramtype = "light",
is_ground_content = false,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
light_source = 5,
})
-- Star
minetest.register_node("x_default:christmas_tree_star", {
description ="Christmas Tree Star",
tiles = {"x_default_christmas_tree_star.png"},
inventory_image = "x_default_christmas_tree_star.png",
wield_image = "x_default_christmas_tree_star.png",
drawtype = "plantlike",
paramtype2 = 0,
paramtype = "light",
walkable = false,
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1},
sounds = default.node_sound_glass_defaults(),
light_source = 5,
})
default.register_leafdecay({
trunks = {"default:pine_tree"},
leaves = {"x_default:christmas_tree_needles"},
radius = 2,
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

74
trees.lua Normal file
View File

@ -0,0 +1,74 @@
--
-- Grow trees from saplings
--
-- 'can grow' function
function x_default.can_grow(pos)
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
if not node_under then
return false
end
local name_under = node_under.name
local is_soil = minetest.get_item_group(name_under, "soil")
if is_soil == 0 then
return false
end
local light_level = minetest.get_node_light(pos)
if not light_level or light_level < 13 then
return false
end
return true
end
-- 'is snow nearby' function
local function is_snow_nearby(pos)
return minetest.find_node_near(pos, 1, {"group:snowy"})
end
-- Grow sapling
function x_default.grow_sapling(pos)
if not default.can_grow(pos) then
-- try again 5 min later
minetest.get_node_timer(pos):start(300)
return
end
local node = minetest.get_node(pos)
if node.name == "x_default:christmas_tree_sapling" then
minetest.log("action", "A christmas tree sapling grows into a tree at "..minetest.pos_to_string(pos))
local snow = is_snow_nearby(pos)
if snow then
x_default.grow_snowy_christmas_tree(pos)
else
x_default.grow_christmas_tree(pos)
end
end
end
-- New pine tree
function x_default.grow_christmas_tree(pos)
local path
if math.random() > 0.5 then
path = minetest.get_modpath("x_default").."/schematics/christmas_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y, z = pos.z - 2}, path, "0", nil, false)
else
path = minetest.get_modpath("x_default").."/schematics/small_christmas_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 1, y = pos.y, z = pos.z - 1}, path, "0", nil, false)
end
end
function x_default.grow_snowy_christmas_tree(pos)
local path
if math.random() > 0.5 then
path = minetest.get_modpath("x_default").."/schematics/snowy_christmas_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y, z = pos.z - 2}, path, "0", nil, false)
else
path = minetest.get_modpath("x_default").."/schematics/snowy_small_christmas_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 1, y = pos.y, z = pos.z - 1}, path, "0", nil, false)
end
end