mirror of
https://github.com/Sokomine/colormachine.git
synced 2024-09-19 10:50:33 +02:00
only consume white dye
This commit is contained in:
parent
356469237d
commit
88e1aed681
31
init.lua
31
init.lua
|
@ -23,6 +23,8 @@
|
||||||
-- Version 0.6
|
-- Version 0.6
|
||||||
|
|
||||||
-- Changelog:
|
-- Changelog:
|
||||||
|
-- 23.05.15 As all dyes can be crafted into other dyes, only white dye is consumed - provided the
|
||||||
|
-- other dyes needed for the crafting chain are stored.
|
||||||
-- 22.05.15 Added support for new homedecor meshnodes.
|
-- 22.05.15 Added support for new homedecor meshnodes.
|
||||||
-- Added support for nodes that use composed textures (by settig composed=1)
|
-- Added support for nodes that use composed textures (by settig composed=1)
|
||||||
-- Added support for myroofs: https://forum.minetest.net/viewtopic.php?f=11&t=11416&p=172034
|
-- Added support for myroofs: https://forum.minetest.net/viewtopic.php?f=11&t=11416&p=172034
|
||||||
|
@ -1065,9 +1067,6 @@ colormachine.get_color_from_blockname = function( mod_name, block_name )
|
||||||
|
|
||||||
-- identify the block type/subname
|
-- identify the block type/subname
|
||||||
local add = "";
|
local add = "";
|
||||||
-- if( not( blocktype ) or blocktype == '' ) then
|
|
||||||
-- blocktype = found[1];
|
|
||||||
-- end
|
|
||||||
|
|
||||||
if( curr_index > 0 ) then
|
if( curr_index > 0 ) then
|
||||||
|
|
||||||
|
@ -1083,6 +1082,10 @@ colormachine.get_color_from_blockname = function( mod_name, block_name )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if( not( blocktype ) or blocktype == '' ) then
|
||||||
|
blocktype = found[1];
|
||||||
|
end
|
||||||
|
|
||||||
if( curr_index > 0 and #liste>0 and liste[1]=='chair' and blocktype == 'homedecor_bed_' ) then
|
if( curr_index > 0 and #liste>0 and liste[1]=='chair' and blocktype == 'homedecor_bed_' ) then
|
||||||
return { error_code = nil,
|
return { error_code = nil,
|
||||||
found_name = found_name,
|
found_name = found_name,
|
||||||
|
@ -1677,13 +1680,23 @@ colormachine.calc_dyes_needed = function( meta, inv, amount_needed, do_consume )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local need_white = math.ceil( amount_needed / anz_pigments );
|
||||||
|
-- the machine does have the required colors stored
|
||||||
|
if( n > 0 ) then
|
||||||
|
local stack_white= inv:get_stack( "dyes", 13 );
|
||||||
|
local anz_white = stack_white:get_count();
|
||||||
|
|
||||||
|
n = math.min( anz_white, need_white );
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- return how many *could* be colored
|
-- return how many *could* be colored
|
||||||
if( amount_needed > 0 and do_consume ~= 1 ) then
|
if( amount_needed > 0 and do_consume ~= 1 ) then
|
||||||
return n*anz_pigments;
|
return n*anz_pigments;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
needed = {};
|
||||||
|
needed[ "white" ] = n;
|
||||||
|
|
||||||
for i,v in ipairs( colormachine.colors_and_greys ) do
|
for i,v in ipairs( colormachine.colors_and_greys ) do
|
||||||
|
|
||||||
|
@ -1705,7 +1718,11 @@ colormachine.calc_dyes_needed = function( meta, inv, amount_needed, do_consume )
|
||||||
local stack = inv:get_stack( "dyes", i );
|
local stack = inv:get_stack( "dyes", i );
|
||||||
local found = stack:get_count();
|
local found = stack:get_count();
|
||||||
--print( ' CONSUMED '..math.floor( n * needed[ v ] )..' of '..tostring( stack:get_name()));
|
--print( ' CONSUMED '..math.floor( n * needed[ v ] )..' of '..tostring( stack:get_name()));
|
||||||
inv:set_stack( "dyes", i, stack:get_name()..' '..tostring( found - math.floor( n * needed[ v ] )));
|
if( found > math.floor( n * needed[ v ] )) then
|
||||||
|
inv:set_stack( "dyes", i, stack:get_name()..' '..tostring( math.max( 1, found - math.floor( n * needed[ v ] ))));
|
||||||
|
else
|
||||||
|
inv:set_stack( "dyes", i, "" );
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2046,6 +2063,10 @@ minetest.register_node("colormachine:colormachine", {
|
||||||
for i,f in ipairs( colormachine.colors_and_greys ) do
|
for i,f in ipairs( colormachine.colors_and_greys ) do
|
||||||
if( k==("mix_"..f )) then
|
if( k==("mix_"..f )) then
|
||||||
colormachine.mix_colors( inv, i, sender );
|
colormachine.mix_colors( inv, i, sender );
|
||||||
|
|
||||||
|
local inv = meta:get_inventory();
|
||||||
|
meta:set_string( 'formspec', colormachine.get_individual_dye_management_formspec( meta, inv ));
|
||||||
|
|
||||||
return; -- formspec remains the dye-management one
|
return; -- formspec remains the dye-management one
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user