Add christmas trees.

This commit is contained in:
Splizard 2012-12-19 11:34:58 +13:00
parent 290f817878
commit 2ae3e27248
5 changed files with 92 additions and 10 deletions

View File

@ -46,6 +46,11 @@ minetest.register_node("snow:needles", {
drop = {
max_items = 1,
items = {
{
-- player will get xmas tree with 1/50 chance
items = {'snow:xmas_tree'},
rarity = 50,
},
{
-- player will get sapling with 1/20 chance
items = {'snow:sapling_pine'},
@ -69,6 +74,57 @@ minetest.register_node("snow:needles", {
sounds = default.node_sound_leaves_defaults(),
})
--Decorated Pine leaves.
minetest.register_node("snow:needles_decorated", {
description = "Decorated Pine Needles",
drawtype = "allfaces_optional",
tiles = {"snow_needles_decorated.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2},
drop = {
max_items = 1,
items = {
{
-- player will get xmas tree with 1/20 chance
items = {'snow:xmas_tree'},
rarity = 50,
},
{
-- player will get sapling with 1/20 chance
items = {'snow:sapling_pine'},
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'snow:needles_decorated'},
}
}
},
--Remove snow above leaves after decay.
after_destruct = function(pos, node, digger)
pos.y = pos.y + 1
local nodename = minetest.env:get_node(pos).name
if nodename == "snow:snow" then
minetest.env:remove_node(pos)
end
end,
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("snow:xmas_tree", {
description = "Christmas Tree",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"snow_xmas_tree.png"},
inventory_image = "snow_xmas_tree.png",
wield_image = "snow_xmas_tree.png",
paramtype = "light",
walkable = false,
groups = {snappy=2,dig_immediate=3,flammable=2},
sounds = default.node_sound_defaults(),
})
minetest.register_node("snow:sapling_pine", {
description = "Pine Sapling",
drawtype = "plantlike",
@ -82,6 +138,18 @@ minetest.register_node("snow:sapling_pine", {
sounds = default.node_sound_defaults(),
})
minetest.register_node("snow:star", {
description = "Star",
drawtype = "torchlike",
tiles = {"snow_star.png"},
inventory_image = "snow_star.png",
wield_image = "snow_star.png",
paramtype = "light",
walkable = false,
groups = {snappy=2,dig_immediate=3},
sounds = default.node_sound_defaults(),
})
minetest.register_craft({
type = "fuel",
recipe = "snow:needles",
@ -401,6 +469,16 @@ minetest.register_abm({
end,
})
--Grow saplings
minetest.register_abm({
nodenames = {"snow:xmas_tree"},
interval = 10,
chance = 50,
action = function(pos, node, active_object_count, active_object_count_wider)
snow.make_pine(pos,false,true)
end,
})
if snow.enable_snowfall then
--Snowing

View File

@ -1,13 +1,15 @@
--Makes pine tree
function snow.make_pine(pos,snow)
function snow.make_pine(pos,snow,xmas)
local env = minetest.env
local perlin1 = env:get_perlin(112,3, 0.5, 150)
local try_node = function(pos, node)
local n = env:get_node(pos).name
if n == "air" or n == "snow:needles" or n == "default:leaves" or n == "snow:sapling_pine" or n == "snow:snow" then
if n == "air" or n == "snow:needles" or n == "default:leaves" or n == "snow:sapling_pine" or n == "snow:snow" or "snow:needles_decorated" then
env:add_node(pos,node)
end
end
local leaves = "snow:needles"
if xmas then leaves = "snow:needles_decorated" end
--Clear ground.
for x=-1,1 do
for z=-1,1 do
@ -27,7 +29,7 @@ function snow.make_pine(pos,snow)
for z=-1,1 do
local x = pos.x + x
local z = pos.z + z
try_node({x=x,y=pos.y+i,z=z},{name="snow:needles"})
try_node({x=x,y=pos.y+i,z=z},{name=leaves})
if snow and x ~= 0 and z ~= 0 and perlin1:get2d({x=x,y=z}) > 0.53 then
try_node({x=x,y=pos.y+i+1,z=z},{name="snow:snow"})
end
@ -38,10 +40,10 @@ function snow.make_pine(pos,snow)
local x = pos.x
local y = pos.y+i
local z = pos.z
try_node({x=x+1,y=y,z=z},{name="snow:needles"})
try_node({x=x-1,y=y,z=z},{name="snow:needles"})
try_node({x=x,y=y,z=z+1},{name="snow:needles"})
try_node({x=x,y=y,z=z-1},{name="snow:needles"})
try_node({x=x+1,y=y,z=z},{name=leaves})
try_node({x=x-1,y=y,z=z},{name=leaves})
try_node({x=x,y=y,z=z+1},{name=leaves})
try_node({x=x,y=y,z=z-1},{name=leaves})
if snow then
if perlin1:get2d({x=x+1,y=z}) > 0.53 then
try_node({x=x+1,y=y+1,z=z},{name="snow:snow"})
@ -59,9 +61,11 @@ function snow.make_pine(pos,snow)
end
try_node({x=pos.x,y=pos.y+i,z=pos.z},{name="default:tree"})
end
try_node({x=pos.x,y=pos.y+5,z=pos.z},{name="snow:needles"})
try_node({x=pos.x,y=pos.y+6,z=pos.z},{name="snow:needles"})
if snow and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
try_node({x=pos.x,y=pos.y+5,z=pos.z},{name=leaves})
try_node({x=pos.x,y=pos.y+6,z=pos.z},{name=leaves})
if xmas then
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:star"})
elseif snow and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:snow"})
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 937 B

BIN
textures/snow_star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

BIN
textures/snow_xmas_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B