Mercurial > hg > batmud > misc
changeset 142:6ea807703d04 misc
Updates.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 21 Dec 2010 00:01:52 +0000 |
parents | 5ae07cabfb95 |
children | e1a130470b84 |
files | materials/mkmaterialinfo.sh materials/parsematerial.pl |
diffstat | 2 files changed, 15 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/materials/mkmaterialinfo.sh Mon Dec 20 23:45:36 2010 +0000 +++ b/materials/mkmaterialinfo.sh Tue Dec 21 00:01:52 2010 +0000 @@ -23,8 +23,7 @@ echo -n "Last updated: " > "$LISTSHORT" date >> "$LISTSHORT" echo "" >> "$LISTSHORT" -perl -w parsematerial.pl -head >> "$LISTSHORT" -cat $DATADIR/*.mat | perl -w parsematerial.pl >> "$LISTSHORT" +cat $DATADIR/*.mat | perl -w parsematerial.pl -table >> "$LISTSHORT" echo "Generating CSV" cat $DATADIR/*.mat | perl -w parsematerial.pl -csv > "$LISTCSV"
--- a/materials/parsematerial.pl Mon Dec 20 23:45:36 2010 +0000 +++ b/materials/parsematerial.pl Tue Dec 21 00:01:52 2010 +0000 @@ -304,17 +304,16 @@ ### ### Check options ### -my $opt_header = 0; my $opt_mode = ""; my $opt_strip = 1; while (defined(my $arg = shift)) { - if ($arg eq "-head") { $opt_header = 1; } - elsif ($arg eq "-csv") { $opt_mode = $arg; } + if ($arg eq "-csv") { $opt_mode = $arg; } elsif ($arg eq "-tf") { $opt_mode = $arg; } elsif ($arg eq "-names") { $opt_mode = $arg; } elsif ($arg eq "-perl") { $opt_mode = $arg; } elsif ($arg eq "-php") { $opt_mode = $arg; } + elsif ($arg eq "-table") { $opt_mode = $arg; } elsif ($arg eq "-dump") { $opt_mode = $arg; $opt_strip = 0; } else { die("Invalid option '$arg'\n"); @@ -326,9 +325,8 @@ ### my %data = (); -if (!$opt_header) { - my $name = ""; - while (<STDIN>) { +my $name = ""; +while (<STDIN>) { chomp; if (/MATERIAL STATS \(([a-z ]+)\)\:/) { $name = $1; @@ -394,7 +392,6 @@ $data{$name}{"refined_names"} = $tmp; @{$data{$name}{"refined_names_arr"}} = split(/, */, $tmp); } - } } # Sort the entries by name @@ -409,22 +406,10 @@ # Create list of known types my @matTypes = sort { $a cmp $b } keys %matByType; -#die(); ### ### Output functionality begins here ### -# Print header -if ($opt_header) { - my $str = ""; - foreach my $info (@fieldInfo) { - $str .= sprintf("%-".$$info{"w"}."s | ", $$info{"s"}); - } - print "$str\n"; - $str =~ s/[^|]/-/g; - $str =~ s/\|/+/g; - print "$str\n"; -} # Print names only if ($opt_mode eq "-names") { @@ -506,6 +491,16 @@ # Print normal table elsif ($opt_mode eq "-table") { + + my $str = ""; + foreach my $info (@fieldInfo) { + $str .= sprintf("%-".$$info{"w"}."s | ", $$info{"s"}); + } + print "$str\n"; + $str =~ s/[^|]/-/g; + $str =~ s/\|/+/g; + print "$str\n"; + foreach my $name (@entries) { my $str = ""; foreach my $info (@fieldInfo) {