One more change to multi-value placeholders: indices start from 0. #1899
This commit is contained in:
parent
a4b6075600
commit
7a9dec3720
@ -43,7 +43,7 @@ sub apply_config {
|
||||
foreach my $opt_key (@opt_keys) {
|
||||
my $value = $config->$opt_key;
|
||||
next unless ref($value) eq 'ARRAY';
|
||||
$m->{"${opt_key}_" . ($_+1)} = $value->[$_] for 0..$#$value;
|
||||
$m->{"${opt_key}_" . $_} = $value->[$_] for 0..$#$value;
|
||||
$m->{$opt_key} = $value->[0];
|
||||
if ($Slic3r::Config::Options->{$opt_key}{type} eq 'point') {
|
||||
$m->{"${opt_key}_X"} = $value->[0];
|
||||
@ -73,8 +73,8 @@ sub process {
|
||||
my $regex = join '|', keys %{$self->_multiple};
|
||||
$string =~ s/\[($regex)\]/$self->_multiple->{$1}/egx;
|
||||
|
||||
# unhandled indices are populated using the first value, except _0 which is ignored for safety
|
||||
$string =~ s/\[($regex)_[1-9]\d*\]/$self->_multiple->{$1}/egx;
|
||||
# unhandled indices are populated using the first value
|
||||
$string =~ s/\[($regex)_\d+\]/$self->_multiple->{$1}/egx;
|
||||
}
|
||||
|
||||
return $string;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use Test::More tests => 14;
|
||||
use Test::More tests => 13;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
@ -88,10 +88,9 @@ use Slic3r::Test;
|
||||
}
|
||||
|
||||
$config->set('start_gcode', qq!
|
||||
;__temp0:[infill_extruder][first_layer_temperature_0]__
|
||||
;__temp0:[first_layer_temperature_0]__
|
||||
;__temp1:[first_layer_temperature_1]__
|
||||
;__temp2:[first_layer_temperature_2]__
|
||||
;__temp3:[first_layer_temperature_3]__
|
||||
!);
|
||||
{
|
||||
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
||||
@ -99,10 +98,9 @@ use Slic3r::Test;
|
||||
# we use the [infill_extruder] placeholder to make sure this test doesn't
|
||||
# catch a false positive caused by the unparsed start G-code option itself
|
||||
# being embedded in the G-code
|
||||
ok $gcode =~ /temp0:1\[/, 'temperature placeholder for _0 ignored';
|
||||
ok $gcode =~ /temp1:200/, 'temperature placeholder for first extruder correctly populated';
|
||||
ok $gcode =~ /temp2:205/, 'temperature placeholder for second extruder correctly populated';
|
||||
ok $gcode =~ /temp3:200/, 'tempearture placeholder for unused extruder populated with first value';
|
||||
ok $gcode =~ /temp0:200/, 'temperature placeholder for first extruder correctly populated';
|
||||
ok $gcode =~ /temp1:205/, 'temperature placeholder for second extruder correctly populated';
|
||||
ok $gcode =~ /temp2:200/, 'tempearture placeholder for unused extruder populated with first value';
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user