corrected color selection from painted blocks

This commit is contained in:
Sokomine 2017-08-08 21:14:00 +02:00
parent 5acf71fa61
commit 890a201456
1 changed files with 9 additions and 9 deletions

View File

@ -1075,26 +1075,26 @@ colormachine.get_color_from_blockname = function( mod_name, block_name, palette_
-- palette_index seems to carry the multiplier in it -- palette_index seems to carry the multiplier in it
local p2 = tonumber(palette_index); local p2 = tonumber(palette_index);
if( data.paramtype2=="colorfacedir" ) then if( data.paramtype2=="colorfacedir" ) then
p2 = (p2/32) - (p2%32); p2 = (p2 - (p2%32))/32;
elseif( data.paramtype2 == "colorwallmounted" ) then elseif( data.paramtype2 == "colorwallmounted" ) then
p2 = (p2/ 8) - (p2% 8); p2 = (p2 - (p2% 8))/ 8;
end end
-- determine the (unifieddyes) name of the color the block has -- determine the (unifieddyes) name of the color the block has
for i,c in ipairs( palette ) do for i,c_data in ipairs( palette ) do
if( c[5] == p2 ) then if( c_data[5] == p2 ) then
if( c[3]==-1 ) then if( c_data[3]==-1 ) then
-- compose the name -- compose the name
found_name = colormachine.colors[c[1] ]; found_name = colormachine.colors[c_data[1] ];
local prefix = colormachine.prefixes[ (c[2]/2) - c[2]%2 ]; local prefix = colormachine.prefixes[ math.floor( (c_data[2] - 1 )/2)+1 ];
local postfix = ""; local postfix = "";
if( c[2]%2==1 ) then if( c_data[2]%2==0 ) then
postfix = "_s50"; postfix = "_s50";
end end
if( found_name and prefix and postfix ) then if( found_name and prefix and postfix ) then
found_name = prefix..found_name..postfix; found_name = prefix..found_name..postfix;
end end
else else
found_name = colormachine.grey_names[c[3]]; found_name = colormachine.grey_names[c_data[3]];
end end
end end
end end