From 2ae3e272483d95c3a77607a742325c0066cca693 Mon Sep 17 00:00:00 2001 From: Splizard Date: Wed, 19 Dec 2012 11:34:58 +1300 Subject: [PATCH] Add christmas trees. --- init.lua | 78 ++++++++++++++++++++++++++++ mapgen.lua | 24 +++++---- textures/snow_needles_decorated.png | Bin 0 -> 937 bytes textures/snow_star.png | Bin 0 -> 540 bytes textures/snow_xmas_tree.png | Bin 0 -> 439 bytes 5 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 textures/snow_needles_decorated.png create mode 100644 textures/snow_star.png create mode 100644 textures/snow_xmas_tree.png diff --git a/init.lua b/init.lua index 0cfc64c..08c864c 100644 --- a/init.lua +++ b/init.lua @@ -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 diff --git a/mapgen.lua b/mapgen.lua index a0659dc..1678ed9 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -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 diff --git a/textures/snow_needles_decorated.png b/textures/snow_needles_decorated.png new file mode 100644 index 0000000000000000000000000000000000000000..f3d6800f19920706c78a25ac8aaba0d7e638608e GIT binary patch literal 937 zcmV;a16KTrP)yQU6GK@--vx4}R$Nwr0j-K73_u zGK>;Np@|Oi#IZ?|K)z^`%UKBi=d3@X{m4eN?^Am;L#sVP_YxLXE9`fMaO9J3SX|i9 zw01&vI*K!M6@*$X=}-z}tU(E;+?4anWn`Mr`gcfNb!ZO9jDr+MNlXKxal}m3p;1uC z)wu%7?c>^6=1Vq9Ma9{Y&1});!D4~Ck)U}z;vb#z&87Lb0Oy07%`fMb$xO{bTzl_v z?IfC+=^RoB!c=p4vG~bHznxx1gKZi-oG}QbN!~J0%H*^^rq>VI>IcYr-oj5c!zkt8 zZl7QK36~d(AAh>lzPk7Ba^t0M4-N~1fPCGdU`zTfpT08K{cFHzQX%}WHkSc!@r#|k zOn=0#siZ_ovw#rMkxT{ zc29^%Q*2}j5KKM0=#}y|OeVGd000McNliru+zb*GH#9w#G5Y`j0jWtu zK~y-)wUSRy6Hye!fA7&Z)0Qw8Mnxc&(1j*OR}D!MKSFnI{T?K)jP9Hbu0#@Cvh9wq z056tFBy`h)T^R9CbkL@;Ei<&wMNQkGf5OJMdda=#+;i_a@IT+)24-&qGp$EXE3QAZ zSa7BfkpMw4ZT4S`PAZkdiONnkd;JnX>n8Uf&GBQ`ijl16Q`~!SV+5Sf&r$t4q@ds- zv~D0%HkHkRl8>h$TL12YtM4q6%YxPo3LYYMgMx?f4;#35lN`K~24KzUkjwV!-*;xr zNhQRu(FX&A&#**g36_=<$YzA=NQAOT%&XYsi7pg8#O$o#j%(qrChb?Mg6ReQXtyaSnx!GZ*MUWax=3)6v5f&IziDj*COy=Cycu70tV>x!n9)Z;pluU zNsJ&UE}G1ejn)C~la_eCUFYR)NapE3_1|RrJ;X literal 0 HcmV?d00001 diff --git a/textures/snow_xmas_tree.png b/textures/snow_xmas_tree.png new file mode 100644 index 0000000000000000000000000000000000000000..357406c19ebf8b05af3752499b4f53b79c2472c0 GIT binary patch literal 439 zcmV;o0Z9IdP)5;&b9jEl*uDOE9%HM`-DUMvBgwr9a`J z9>AoXc987iHlY|J_h`$})CoO

R!WW#Q8rsQ@OfnAKc{jt+L`y{?%h-&O99B2?LX zbF4PE3US6To_&#eb9eu`^qAaY0MMf9`0059g)!+D+Vhy~az4BjVILde5Z*s$2q_B2 hlj-K|@L}raegn=kcuB4}Hw6Fy002ovPDHLkV1f>$yX^n~ literal 0 HcmV?d00001