Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- $directory = "./Mods/AutoGen/WorldObject";
- if ( !opendir( DIR, $directory ) ) { die "Could not open $directory"; }
- while (readdir DIR) {
- if ( $_ =~ /.+\.cs$/ ) { checkFile("$directory/$_"); }
- }
- closedir DIR;
- @items = sort {
- return $a->{'Category'} cmp $b->{'Category'} ||
- $a->{'TypeForRoomLimit'} cmp $b->{'TypeForRoomLimit'} ||
- $b->{'Val'} <=> $a->{'Val'} ;
- } @items;
- open(OUTPUT,">EcoFurniture.csv") or die "Could not open outputfile\n";
- print OUTPUT "Item Type,Name,Value,Diminish\n";
- foreach $itemRef ( @items ) {
- %item = %$itemRef;
- if ( $item{'Category'} ne $current ) { print OUTPUT "\n$item{'Category'}\n"; $current = $item{'Category'} }
- print OUTPUT"$item{'TypeForRoomLimit'},$item{'name'},$item{'Val'},$item{'DiminishingReturnPercent'}\n";
- }
- sub checkFile {
- my ( $fileName ) = @_;
- if ( !open(INPUT,"<$fileName") ) {
- print "Could not open $fileName\n";
- return;
- }
- my $isHouseItem = 0;
- my %item = ();
- while (<INPUT>)
- {
- if ( $_ =~ /HousingVal/ ) { $isHouseItem = 1 }
- if ( $_ =~ /public override string FriendlyName \{ get \{ return "(.+)";/ ) { $item{'name'} = $1; }
- if ( $_ =~ /Category = "(.+)"/ ) { $item{'Category'} = $1; }
- if ( $_ =~ /TypeForRoomLimit = "(.+)"/ ) { $item{'TypeForRoomLimit'} = $1; }
- if ( $_ =~ /DiminishingReturnPercent = (.+)f/ ) { $item{'DiminishingReturnPercent'} = $1; }
- if ( $_ =~ /Val = (.+?)f?,/ ) { $item{'Val'} = $1; }
- }
- #if ( $isHouseItem ) { print "$item{'name'} $item{'Val'} $item{'Category'} $item{'TypeForRoomLimit'} $item{'DiminishingReturnPercent'}\n"; }
- if ( $isHouseItem ) { push(@items,\%item); }
- close INPUT;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement