Updated Converter

This commit is contained in:
Florian Kinder
2014-02-12 23:53:21 +01:00
parent 0c4323b28d
commit 99791dec20
2 changed files with 6 additions and 3 deletions

View File

@@ -24,7 +24,6 @@ while (my $line = <CFG>) {
else {
$small = 0;
}
}
elsif ($collect == 1 && $line =~ /^\s*\{\s*"(\w*)",\s*"(\w*)"\s*\}/i) {
push(@itemType, {
@@ -49,7 +48,7 @@ while (my $line = <CFG>) {
$cfg .= "\t\titemChance[] = {\n" if $small == 0;
$cfg .= "\t\titemChanceSmall[] = {\n" if $small == 1;
for (my $i=0; $i<scalar(@itemType); $i++) {
$cfg .= sprintf("\t\t\t%s{\"%s\",\"%s\",%.3f}\n", ($i > 0 ? ',' : ''), $itemType[$i]->{Class}, $itemType[$i]->{Type}, $itemChance[$i]);
$cfg .= sprintf("\t\t\t%s{\"%s\",\"%s\",%.2f}\n", ($i > 0 ? ',' : ''), $itemType[$i]->{Class}, $itemType[$i]->{Type}, $itemChance[$i]);
}
$cfg .= "\t\t};\n";
}
@@ -59,6 +58,8 @@ while (my $line = <CFG>) {
}
close(CFG);
$cfg =~ s/(\d+\.\d+)[0]+\}\s*$/$1}/gm;
open(NEWCFG,'>', $configFile) or die $!;
print NEWCFG $cfg;
close(NEWCFG);

View File

@@ -30,7 +30,7 @@ while (my $line = <CFG>) {
$collect = 0;
for (my $i=0; $i<scalar(@itemType); $i++) {
$cfg .= sprintf("\t\t%s{\"%s\",%.3f}\n", ($i > 0 ? ',' : ''), $itemType[$i], $itemChance[$i]);
$cfg .= sprintf("\t\t%s{\"%s\",%.2f}\n", ($i > 0 ? ',' : ''), $itemType[$i], $itemChance[$i]);
}
$cfg .= "\t};\n";
@@ -41,6 +41,8 @@ while (my $line = <CFG>) {
}
close(CFG);
$cfg =~ s/(\d+\.\d+)[0]+\}\s*$/$1}/gm;
open(NEWCFG,'>', $configFile) or die $!;
print NEWCFG $cfg;
close(NEWCFG);