added panels and microblocks

This commit is contained in:
Sokomine 2014-07-24 02:38:42 +02:00
parent d72254a104
commit 7dd1406f24
4 changed files with 68 additions and 5 deletions

View File

@ -35,6 +35,8 @@ moresnow.c_snow = minetest.get_content_id( 'default:snow' );
moresnow.c_snow_top = minetest.get_content_id( 'moresnow:snow_top' );
moresnow.c_snow_stair = minetest.get_content_id( 'moresnow:snow_stair_top' );
moresnow.c_snow_slab = minetest.get_content_id( 'moresnow:snow_slab_top' );
moresnow.c_snow_panel = minetest.get_content_id( 'moresnow:snow_panel_top' );
moresnow.c_snow_micro = minetest.get_content_id( 'moresnow:snow_micro_top' );
moresnow.c_snow_outer_stair = minetest.get_content_id( 'moresnow:snow_outer_stair_top' );
moresnow.c_snow_inner_stair = minetest.get_content_id( 'moresnow:snow_inner_stair_top' );
moresnow.c_snow_ramp_top = minetest.get_content_id( 'moresnow:snow_ramp_top' );

View File

@ -86,6 +86,34 @@ moresnow.identify_stairs_and_slabs = function()
moresnow.snow_cover[ id ] = moresnow.c_snow_slab;
-- panels (=half slabs)
elseif((#nb == 1
and math.max( nb[1][2], nb[1][5])==0
and math.abs( nb[1][4] - nb[1][1] ) >= 0.9
and math.abs( nb[1][6] - nb[1][3] ) <= 0.5 )
or ( type( nb[1] )~='table'
and #nb == 6
and math.max( nb[2], nb[5] )==0
and math.abs( nb[4]-nb[1] ) >= 0.9
and math.abs( nb[6]-nb[3] ) <= 0.5 )) then
moresnow.snow_cover[ id ] = moresnow.c_snow_panel;
-- micro(blocks)
elseif((#nb == 1
and math.max( nb[1][2], nb[1][5])==0
and math.abs( nb[1][4] - nb[1][1] ) >= 0.5
and math.abs( nb[1][6] - nb[1][3] ) <= 0.5 )
or ( type( nb[1] )~='table'
and #nb == 6
and math.max( nb[2], nb[5] )==0
and math.abs( nb[4]-nb[1] ) >= 0.5
and math.abs( nb[6]-nb[3] ) <= 0.5 )) then
moresnow.snow_cover[ id ] = moresnow.c_snow_micro;
-- might be a stair
elseif( #nb == 2 ) then
local c = { math.min( nb[1][1], nb[1][4] ), math.min( nb[1][2], nb[1][5] ), math.min( nb[1][3], nb[1][4] ),

View File

@ -111,7 +111,7 @@ if( moresnow.enable_autumnleaves ) then
})
end
if( moresnow.enable_wool and minetest.get_modpath( 'wool' ) and moresnow.wool_dyes) then
if( moresnow.wool_dyes and minetest.get_modpath( 'wool' )) then
for _,v in ipairs( moresnow.wool_dyes ) do
table.insert( moresnow.nodetypes, 'wool_'..v );
minetest.register_node( "moresnow:wool_"..v, {
@ -165,6 +165,23 @@ moresnow.register_snow_top( "slab_top", { {-0.5, -1.0, -0.5, 0.5, -1.0+2/16, 0.5
-- these shapes exist in moreblocks only
if( minetest.get_modpath( 'moreblocks' )) then
moresnow.register_snow_top( "panel_top", {
{-0.5, -1.5, -0.5, 0.5, -1.5+2/16, 0},
{-0.5, -1.0, 0, 0.5, -1.0+2/16, 0.5},
{-0.5, -1.5+2/16, 0-1/32, 0.5, -1.0, 0 },
},{ -- the wool version does not have the wool covering the legs
{-0.5, -1.0, 0, 0.5, -1.0+2/16, 0.5},
});
moresnow.register_snow_top( "micro_top", {
{-0.5, -1.5, -0.5, 0, -1.5+2/16, 0 },
{-0.5, -1.0, 0, 0, -1.0+2/16, 0.5},
{ 0, -1.5, -0.5, 0.5, -1.5+2/16, 0.5},
{-0.5, -1.5+2/16, 0-1/32, 0, -1.0, 0 },
{0, -1.5+2/16, 0, 0+1/32, -1.0, 0.5},
},{ -- the wool version does not have the wool covering the legs
{-0.5, -1.0, 0, 0, -1.0+2/16, 0.5},
});
moresnow.register_snow_top( "outer_stair_top", {
{-0.5, -1.0, -0.5, 0, -1.0+2/16, 0 },
{-0.5, -0.5, 0, 0, -0.5+2/16, 0.5},

View File

@ -4,7 +4,7 @@ moresnow.translation_table = {}
moresnow.build_translation_table = function()
local shapes = {'top', 'stair_top', 'slab_top',
'outer_stair_top', 'inner_stair_top',
'panel_top', 'micro_top', 'outer_stair_top', 'inner_stair_top',
'ramp_top', 'ramp_outer_top', 'ramp_inner_top' };
for _,t in ipairs(moresnow.nodetypes) do
@ -110,17 +110,29 @@ moresnow.suggest_snow_type = function( node_content_id, p2 )
if( p2 >= 4 and p2 <= 19 ) then
suggested = moresnow.c_snow_top;
-- slab turned upside down
elseif( p2 >= 20 and p2 <= 23 ) then
elseif( p2 >= 20 and p2 <= 24 ) then
suggested = moresnow.c_snow;
-- else it's a slab
end
elseif( suggested == moresnow.c_snow_panel ) then
-- vertical panel (mostly); can't be handled well; therefore, treat as a nodebox
if( p2 >= 4 and p2 <= 24 ) then
suggested = moresnow.c_snow_top;
end
elseif( suggested == moresnow.c_snow_micro ) then
-- microblocks in diffrent positions from the normal ones are too difficult
if( p2 >= 4 and p2 <= 24 ) then
suggested = moresnow.c_snow_top;
end
elseif( suggested == moresnow.c_snow_ramp_outer ) then
-- treat like a nodebox
if( p2>=4 and p2 <= 19 ) then
suggested = moresnow.c_snow_top;
-- upside-down
elseif( p2 >= 20 and p2 <= 23 ) then
elseif( p2 >= 20 and p2 <= 24 ) then
suggested = moresnow.c_snow;
end
@ -129,11 +141,15 @@ moresnow.suggest_snow_type = function( node_content_id, p2 )
if( p2>=4 and p2 <= 19 ) then
suggested = moresnow.c_snow_top;
-- upside-down
elseif( p2 >= 20 and p2 <= 23 ) then
elseif( p2 >= 20 and p2 <= 24 ) then
suggested = moresnow.c_snow;
end
end
-- c_snow_top does not have facedir
if( suggested == moresnow.c_snow_top ) then
p2 = 1;
end
return { new_id = suggested, param2 = p2 };
end