make sure your browser window is wide enough not to line-wrap anything. Then run
cat > ~/bin/springmod-unittable.pl
copy/paste, and hit ctrl-d.
run as springmod-unittable.pl units/* > unittable.dat
(e.g. after unpacking a mod, with mkdir BA; cd BA; 7z x /foo/bar/BA58.sd7)
OpenOffice can load the file with "new sheet from file". It can probably "link to external data" and keep refreshing itself from the file if it changes, but I didn't figure out how to get that to work.
One thing you should do is click on the D2 cell, and go to windows->freeze to keep the column headers and unit names fixed while you scroll the other part of the window.
------
Code: Select all
#!/usr/bin/perl -w
# Copyright 2007, Peter Cordes <peter@cordes.ca>
# GPL
# turn a directory of .fbi files into a table of unit stats
# suitable for viewing and sorting with a spreadsheet program
# doesn't go the other way, so you have to edit the fbi files, though.
# yes this is a quick hack. no it doesn't get weapon stats.
use Config::File;
# rows are from an array of hash refs for each unit. plain hashes collapse when pushed...
my @allunits;
# we need to know all the keys that any unit has. These are the table columns
#my $filter = qr/germanname|weaponslaveto4/
my @taglist = ("unitname", "name", "description", "side", "buildcostenergy", "buildcostmetal", "buildtime", "maxdamage", "maxvelocity", "maxslope", "sightdistance", "radardistance", "sonardistance", "radardistancejam", "builddistance", "mincloakdistance", "cloakcost", "transportcapacity", "transportsize", "weapon1", "weapon2", "weapon3", "workertime" );
# TODO do something about the order here.
# after these fixed ones, discovered ones are added in whatever order they appear in the hash.
my %allkeys;
map $allkeys{$_}=1, @taglist;
foreach $fbi (@ARGV){
my $config_hash = Config::File::read_config_file($fbi) || die "bad unit file $fbi";
# map {s/; *$//} values %$config_hash;
# copy into a new hash with changed keys and values
my %unithash;
foreach $key (keys %$config_hash){
my $lckey = lc($key);
if (!exists($allkeys{$lckey})){
$allkeys{$lckey} = 1;
push @taglist, $lckey;
}
($unithash{$lckey} = $$config_hash{$key}) =~ s/; *$//; # clean up trailing junk
}
push @allunits, \%unithash;
}
#@taglist = sort(keys %allkeys);
print join("|", @taglist), "\n";
foreach $unit (@allunits){
my @unitstats = map( $$unit{$_} || "", @taglist);
print join("|", @unitstats), "\n";
}