mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Added Converter for cfgLoot
This commit is contained in:
48
Tools/Loot Position/ConvertLoottables2.pl
Normal file
48
Tools/Loot Position/ConvertLoottables2.pl
Normal file
@@ -0,0 +1,48 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Data::Dumper;
|
||||
|
||||
# Customize
|
||||
my $configFile = '../../SQF/dayz_code/Configs/CfgBuildingLoot/cfgLoot.hpp';
|
||||
|
||||
# do not touch
|
||||
my $cfg = '';
|
||||
my $collect = 0;
|
||||
my $small = 0;
|
||||
my @itemType;
|
||||
my @itemChance;
|
||||
open(CFG, '<', $configFile) or die $!;
|
||||
while (my $line = <CFG>) {
|
||||
if ($line =~ /^\s*(\w+)\[\]\s*=\s*\{/i) {
|
||||
$collect = 1;
|
||||
$cfg .= "\t".$1."[] = {\n";
|
||||
}
|
||||
elsif ($collect == 1 && $line =~ /^\s*"([^"]+)"/) {
|
||||
push(@itemType, $1);
|
||||
}
|
||||
elsif ($collect == 1 && $line =~ /^\s*\},/) {
|
||||
$collect = 2;
|
||||
}
|
||||
elsif ($collect == 2 && $line =~ /^\s*(\d+\.\d+),?/) {
|
||||
push(@itemChance, $1);
|
||||
}
|
||||
elsif ($collect == 2 && $line =~ /^\t\}/) {
|
||||
$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 .= "\t};\n";
|
||||
}
|
||||
elsif ($collect == 0 && $line !~ /^\s*\/\// && $line !~ /^\s*$/) {
|
||||
$cfg .= $line;
|
||||
}
|
||||
}
|
||||
close(CFG);
|
||||
|
||||
open(NEWCFG,'>', $configFile) or die $!;
|
||||
print NEWCFG $cfg;
|
||||
close(NEWCFG);
|
||||
|
||||
exit(0);
|
||||
Reference in New Issue
Block a user