added method to select type of plaster through source block

This commit is contained in:
Sokomine 2018-01-27 19:11:16 +01:00
parent 4a60d7b7be
commit 922223df51
3 changed files with 29 additions and 11 deletions

View File

@ -7,7 +7,7 @@ plasterwork.palette = "unifieddyes_palette_extended.png";
-- this block will - when scanned - turn into a randomly plastered one; -- this block will - when scanned - turn into a randomly plastered one;
-- make sure that block has a description -- make sure that block has a description
plasterwork.random_block = "default:copperblock"; plasterwork.random_block = "default:bronzeblock";
-- each scan (adjustment to new plaster and color type) costs that much: -- each scan (adjustment to new plaster and color type) costs that much:
plasterwork.scan_price = "default:mese_crystal_fragment"; plasterwork.scan_price = "default:mese_crystal_fragment";

View File

@ -25,12 +25,26 @@ plasterwork.update_formspec = function(pos, meta, inv)
local node_below = minetest.get_node( {x=pos.x, y=pos.y-1, z=pos.z}); local node_below = minetest.get_node( {x=pos.x, y=pos.y-1, z=pos.z});
if( can_pay and node_below and node_below.name) then
local old_name = node_below.name;
-- exchange the node below with a random plastered one -- exchange the node below with a random plastered one
if( can_pay and node_below and node_below.name and node_below.name == plasterwork.random_block) then if( node_below.name == plasterwork.random_block) then
node_below.name = plasterwork.node_list[ math.random( 1, #plasterwork.node_list )]; node_below.name = plasterwork.node_list[ math.random( 1, #plasterwork.node_list )];
-- ..or with a specific one if it is the right type
else
for k,v in pairs( plasterwork.supported ) do
if( k and v and v[3] and v[3]==node_below.name ) then
node_below.name = k;
end
end
end
-- we found a new one
if( old_name ~= node_below.name ) then
node_below.param2 = math.random(0,255); node_below.param2 = math.random(0,255);
minetest.set_node( {x=pos.x, y=pos.y-1, z=pos.z}, node_below ); minetest.set_node( {x=pos.x, y=pos.y-1, z=pos.z}, node_below );
end end
end
if( not( can_pay ) or not( node_below ) or not( node_below.name ) if( not( can_pay ) or not( node_below ) or not( node_below.name )
or not( minetest.registered_nodes[ node_below.name ]) or not( minetest.registered_nodes[ node_below.name ])

View File

@ -3,7 +3,8 @@
-- Even if the lumps would be colored, that would still be inconvenient due -- Even if the lumps would be colored, that would still be inconvenient due
-- to too many non-stacking nodes filling up the player's inventory. -- to too many non-stacking nodes filling up the player's inventory.
plasterwork.register_plaster_node = function( node_name, description, image, palette, price_node, price_amount ) plasterwork.register_plaster_node = function( node_name, description, image, palette, price_node, price_amount,
randomly_from_source_block )
minetest.register_node( node_name, { minetest.register_node( node_name, {
description = description, description = description,
tiles = {image}, tiles = {image},
@ -18,15 +19,18 @@ plasterwork.register_plaster_node = function( node_name, description, image, pal
if( not( plasterwork.supported[ node_name ])) then if( not( plasterwork.supported[ node_name ])) then
table.insert( plasterwork.node_list, node_name ); table.insert( plasterwork.node_list, node_name );
end end
plasterwork.supported[ node_name ] = { price_node, price_amount }; plasterwork.supported[ node_name ] = { price_node, price_amount, randomly_from_source_block };
end end
end end
plasterwork.register_plaster_node( "plasterwork:rough_plaster", "Stone with clay plaster", plasterwork.register_plaster_node( "plasterwork:rough_plaster", "Stone with clay plaster",
"default_clay.png", plasterwork.palette, "default:cobble", 2 ); "default_clay.png", plasterwork.palette, "default:cobble", 2, "default:copperblock" );
plasterwork.register_plaster_node( "plasterwork:smooth_plaster", "Stone with smooth plaster", plasterwork.register_plaster_node( "plasterwork:smooth_plaster", "Stone with smooth plaster",
"default_coral_skeleton.png", plasterwork.palette, "default:cobble", 4 ); "default_coral_skeleton.png", plasterwork.palette, "default:cobble", 4, "default:steelblock" );
plasterwork.register_plaster_node( "plasterwork:tin_plaster", "Stone with metallic plaster", plasterwork.register_plaster_node( "plasterwork:tin_plaster", "Stone with metallic plaster",
"default_tin_block.png", plasterwork.palette, "default:cobble", 6 ); "default_tin_block.png", plasterwork.palette, "default:cobble", 6, "default:tinblock" );
plasterwork.register_plaster_node( "plasterwork:sandstone_plaster", "Stone with sandstone plaster",
"default_sandstone.png", plasterwork.palette, "default:cobble", 6, "default:goldblock" );