From 895f9c3e9e4635ff042c51ae50c2353ba26eefe4 Mon Sep 17 00:00:00 2001 From: Splizard Date: Tue, 18 Dec 2012 11:36:19 +1300 Subject: [PATCH] Hide papyrus in snow. --- init.lua | 18 ++++++++++++++++++ mapgen.lua | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/init.lua b/init.lua index 197450a..47929c8 100644 --- a/init.lua +++ b/init.lua @@ -246,12 +246,30 @@ minetest.register_on_dignode(unsnowify) minetest.register_node("snow:snow_block", { description = "Snow", tiles = {"snow_snow.png"}, + --param2 is reserved for what vegetation is hiding inside. + --mapgen defines the vegetation. + --1 = Moss + --2 = Papyrus is_ground_content = true, groups = {crumbly=3,melts=2,falling_node=1}, drop = 'snow:snow_block', sounds = default.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.4}, }), + --Update dirt node underneath snow. + after_destruct = function(pos, node, digger) + if node.param2 == 1 then + local n = minetest.env:get_node(pos).name + if n == "air" or n == "default:water_flowing" or n == "default:water_source" then + minetest.env:add_node(pos,{name="snow:moss",param2=1}) + end + elseif node.param2 == 2 then + local n = minetest.env:get_node(pos).name + if n == "air" or n == "default:water_flowing" or n == "default:water_source" then + minetest.env:add_node(pos,{name="default:papyrus"}) + end + end + end, }) --Snow brick. diff --git a/mapgen.lua b/mapgen.lua index d0ff868..5b44abb 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -192,6 +192,13 @@ if maxp.y >= -10 then end elseif ground_y and env:get_node({x=x,y=ground_y,z=z}).name == "default:leaves" then env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow"}) + elseif ground_y and env:get_node({x=x,y=ground_y,z=z}).name == "default:papyrus" then + for i=ground_y, ground_y-4, -1 do + if env:get_node({x=x,y=i,z=z}).name == "default:papyrus" then + env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow"}) + env:add_node({x=x,y=i,z=z}, {name="snow:snow_block", param2=2}) + end + end elseif ground_y and node.name == "default:water_source" then if not icesheet and not icecave and not icehole then --Coastal ice.