added method to select type of plaster through source block
This commit is contained in:
parent
4a60d7b7be
commit
922223df51
2
init.lua
2
init.lua
@ -7,7 +7,7 @@ plasterwork.palette = "unifieddyes_palette_extended.png";
|
||||
|
||||
-- this block will - when scanned - turn into a randomly plastered one;
|
||||
-- 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:
|
||||
plasterwork.scan_price = "default:mese_crystal_fragment";
|
||||
|
24
machine.lua
24
machine.lua
@ -25,11 +25,25 @@ plasterwork.update_formspec = function(pos, meta, inv)
|
||||
|
||||
local node_below = minetest.get_node( {x=pos.x, y=pos.y-1, z=pos.z});
|
||||
|
||||
-- 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
|
||||
node_below.name = plasterwork.node_list[ math.random( 1, #plasterwork.node_list )];
|
||||
node_below.param2 = math.random(0,255);
|
||||
minetest.set_node( {x=pos.x, y=pos.y-1, z=pos.z}, node_below );
|
||||
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
|
||||
if( node_below.name == plasterwork.random_block) then
|
||||
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);
|
||||
minetest.set_node( {x=pos.x, y=pos.y-1, z=pos.z}, node_below );
|
||||
end
|
||||
end
|
||||
|
||||
if( not( can_pay ) or not( node_below ) or not( node_below.name )
|
||||
|
14
nodes.lua
14
nodes.lua
@ -3,7 +3,8 @@
|
||||
-- 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.
|
||||
|
||||
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, {
|
||||
description = description,
|
||||
tiles = {image},
|
||||
@ -18,15 +19,18 @@ plasterwork.register_plaster_node = function( node_name, description, image, pal
|
||||
if( not( plasterwork.supported[ node_name ])) then
|
||||
table.insert( plasterwork.node_list, node_name );
|
||||
end
|
||||
plasterwork.supported[ node_name ] = { price_node, price_amount };
|
||||
plasterwork.supported[ node_name ] = { price_node, price_amount, randomly_from_source_block };
|
||||
end
|
||||
end
|
||||
|
||||
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",
|
||||
"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",
|
||||
"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" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user