add snow covered snow shrub

This commit is contained in:
HybridDog 2015-06-17 19:29:43 +02:00
parent f82c525222
commit 6dbbf90f34
4 changed files with 28 additions and 47 deletions

View File

@ -74,17 +74,6 @@ function snow.make_pine(pos,snow,xmas)
minetest.add_node(pos, node) minetest.add_node(pos, node)
end end
end end
--Clear ground.
for z = -1,1 do
for x = -1,1 do
local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
local nd = minetest.get_node(p).name
if nd == "default:snow"
or nd == "default:snowblock" then
minetest.remove_node(p)
end
end
end
if xmas then if xmas then
minetest.remove_node(pos) minetest.remove_node(pos)
minetest.spawn_tree(pos, xmas_tree) minetest.spawn_tree(pos, xmas_tree)
@ -126,18 +115,10 @@ function snow.voxelmanip_pine(pos,a,data)
for x = -1,1 do for x = -1,1 do
local x = pos.x + x local x = pos.x + x
--Clear ground.
local node = a:index(x,pos.y,z)
if data[node] == c_snow then
data[node] = c_air
end
--Make tree. --Make tree.
for i = 1,2 do for i = 1,2 do
local node = a:index(x,pos.y+i,z) data[a:index(x,pos.y+i,z)] = c_pine_needles
data[node] = c_pine_needles if x ~= 0
if snow
and x ~= 0
and z ~= 0 and z ~= 0
and perlin1:get2d({x=x,y=z}) > 0.53 then and perlin1:get2d({x=x,y=z}) > 0.53 then
local abovenode = a:index(x,pos.y+i+1,z) local abovenode = a:index(x,pos.y+i+1,z)
@ -154,7 +135,6 @@ function snow.voxelmanip_pine(pos,a,data)
data[a:index(x-1,y,z)] = c_pine_needles data[a:index(x-1,y,z)] = c_pine_needles
data[a:index(x,y,z+1)] = c_pine_needles data[a:index(x,y,z+1)] = c_pine_needles
data[a:index(x,y,z-1)] = c_pine_needles data[a:index(x,y,z-1)] = c_pine_needles
if snow then
if perlin1:get2d({x=x+1,y=z}) > 0.53 then if perlin1:get2d({x=x+1,y=z}) > 0.53 then
data[a:index(x+1,y+1,z)] = c_snow data[a:index(x+1,y+1,z)] = c_snow
end end
@ -168,14 +148,12 @@ function snow.voxelmanip_pine(pos,a,data)
data[a:index(x,y+1,z-1)] = c_snow data[a:index(x,y+1,z-1)] = c_snow
end end
end end
end
for i=0, 4 do for i=0, 4 do
data[a:index(pos.x,pos.y+i,pos.z)] = c_pinetree data[a:index(pos.x,pos.y+i,pos.z)] = c_pinetree
end end
data[a:index(pos.x,pos.y+5,pos.z)] = c_pine_needles data[a:index(pos.x,pos.y+5,pos.z)] = c_pine_needles
data[a:index(pos.x,pos.y+6,pos.z)] = c_pine_needles data[a:index(pos.x,pos.y+6,pos.z)] = c_pine_needles
if snow if perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
data[a:index(pos.x,pos.y+7,pos.z)] = c_snow data[a:index(pos.x,pos.y+7,pos.z)] = c_snow
end end
end end

View File

@ -92,7 +92,7 @@ local function define_contents()
ignore = minetest.get_content_id("ignore"), ignore = minetest.get_content_id("ignore"),
stone = minetest.get_content_id("default:stone"), stone = minetest.get_content_id("default:stone"),
dry_shrub = minetest.get_content_id("default:dry_shrub"), dry_shrub = minetest.get_content_id("default:dry_shrub"),
snow_shrub = minetest.get_content_id("snow:shrub"), snow_shrub = minetest.get_content_id("snow:shrub_covered"),
leaves = minetest.get_content_id("default:leaves"), leaves = minetest.get_content_id("default:leaves"),
jungleleaves = minetest.get_content_id("default:jungleleaves"), jungleleaves = minetest.get_content_id("default:jungleleaves"),
junglegrass = minetest.get_content_id("default:junglegrass"), junglegrass = minetest.get_content_id("default:junglegrass"),
@ -122,6 +122,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
local data = vm:get_data() local data = vm:get_data()
local param2s = vm:get_param2_data()
local snow_tab,num = {},1 local snow_tab,num = {},1
@ -343,6 +344,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- replace other plants with shrubs -- replace other plants with shrubs
data[vi] = c.dirt_with_snow data[vi] = c.dirt_with_snow
data[node] = known_plants[c_ground] or c.snow_shrub data[node] = known_plants[c_ground] or c.snow_shrub
param2s[node] = pr:next(0,179)
end end
end end
end end
@ -351,7 +353,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
local param2s
if num ~= 1 then if num ~= 1 then
for _,i in pairs(snow_tab) do for _,i in pairs(snow_tab) do
-- set snow -- set snow
@ -394,9 +395,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
data[vi] = c.snow_block data[vi] = c.snow_block
else else
-- set a specific snow height -- set a specific snow height
if not param2s then
param2s = vm:get_param2_data()
end
param2s[vi] = h*7 param2s[vi] = h*7
end end
end end
@ -407,9 +405,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
vm:set_data(data) vm:set_data(data)
if param2s then
vm:set_param2_data(param2s) vm:set_param2_data(param2s)
end
vm:set_lighting({day=0, night=0}) vm:set_lighting({day=0, night=0})
vm:calc_lighting() vm:calc_lighting()
vm:write_to_map() vm:write_to_map()

View File

@ -159,8 +159,8 @@ minetest.register_node("snow:moss", {
groups = {crumbly=3, attached_node=1}, groups = {crumbly=3, attached_node=1},
}) })
-- Shrub -- Shrub(s)
minetest.register_node("snow:shrub", { nodedef = {
description = "Snow Shrub", description = "Snow Shrub",
tiles = {"snow_shrub.png"}, tiles = {"snow_shrub.png"},
inventory_image = "snow_shrub.png", inventory_image = "snow_shrub.png",
@ -178,7 +178,14 @@ minetest.register_node("snow:shrub", {
type = "fixed", type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, -5/16, 0.3}, fixed = {-0.3, -0.5, -0.3, 0.3, -5/16, 0.3},
}, },
}) }
minetest.register_node("snow:shrub", table.copy(nodedef))
nodedef.tiles = {"snow_shrub.png^snow_shrub_covering.png"}
nodedef.inventory_image = "snow_shrub.png^snow_shrub_covering.png"
nodedef.wield_image = "snow_shrub.png^snow_shrub_covering.png"
nodedef.drop = "snow:shrub"
minetest.register_node("snow:shrub_covered", nodedef)

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B