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)
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
minetest.remove_node(pos)
minetest.spawn_tree(pos, xmas_tree)
@ -126,18 +115,10 @@ function snow.voxelmanip_pine(pos,a,data)
for x = -1,1 do
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.
for i = 1,2 do
local node = a:index(x,pos.y+i,z)
data[node] = c_pine_needles
if snow
and x ~= 0
data[a:index(x,pos.y+i,z)] = c_pine_needles
if x ~= 0
and z ~= 0
and perlin1:get2d({x=x,y=z}) > 0.53 then
local abovenode = a:index(x,pos.y+i+1,z)
@ -154,19 +135,17 @@ function snow.voxelmanip_pine(pos,a,data)
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
if snow then
if perlin1:get2d({x=x+1,y=z}) > 0.53 then
data[a:index(x+1,y+1,z)] = c_snow
end
if perlin1:get2d({x=x+1,y=z}) > 0.53 then
data[a:index(x-1,y+1,z)] = c_snow
end
if perlin1:get2d({x=x,y=z+1}) > 0.53 then
data[a:index(x,y+1,z+1)] = c_snow
end
if perlin1:get2d({x=x,y=z-1}) > 0.53 then
data[a:index(x,y+1,z-1)] = c_snow
end
if perlin1:get2d({x=x+1,y=z}) > 0.53 then
data[a:index(x+1,y+1,z)] = c_snow
end
if perlin1:get2d({x=x+1,y=z}) > 0.53 then
data[a:index(x-1,y+1,z)] = c_snow
end
if perlin1:get2d({x=x,y=z+1}) > 0.53 then
data[a:index(x,y+1,z+1)] = c_snow
end
if perlin1:get2d({x=x,y=z-1}) > 0.53 then
data[a:index(x,y+1,z-1)] = c_snow
end
end
for i=0, 4 do
@ -174,8 +153,7 @@ function snow.voxelmanip_pine(pos,a,data)
end
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
if snow
and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
if perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
data[a:index(pos.x,pos.y+7,pos.z)] = c_snow
end
end

View File

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

View File

@ -159,8 +159,8 @@ minetest.register_node("snow:moss", {
groups = {crumbly=3, attached_node=1},
})
-- Shrub
minetest.register_node("snow:shrub", {
-- Shrub(s)
nodedef = {
description = "Snow Shrub",
tiles = {"snow_shrub.png"},
inventory_image = "snow_shrub.png",
@ -178,7 +178,14 @@ minetest.register_node("snow:shrub", {
type = "fixed",
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