chiark / gitweb /
Version bump.
[rocl] / elite-describe
1 #! /usr/bin/tclsh
2 #
3 # $Id: elite-describe,v 1.2 2003/02/25 00:25:38 mdw Exp $
4
5 package require "elite" "1.0.0"
6
7 proc describe n {
8   global economy government
9   elite-worldinfo p $n
10   puts "Name: $p(name)"
11   puts "Position: $p(x), $p(y) LY"
12   puts "Economy: $economy($p(economy))"
13   puts "Government: $government($p(government))"
14   puts "Tech. level: $p(techlevel)"
15   puts [format "Population: %s billion (%s)" \
16       [expr {$p(population)/10.0}] $p(inhabitants)]
17   puts "Gross productivity: $p(productivity) M Cr"
18   puts "Radius: $p(radius) km"
19   puts ""
20   set ll {}
21   set l 0
22   foreach w $p(description) {
23     incr l
24     incr l [string length $w]
25     if {$l > 72} { puts $ll; set ll {}; set l 0 }
26     lappend ll $w
27   }
28   puts $ll
29 }
30
31 if {[llength $argv] < 1} {
32   puts stderr "usage: $argv0 \[-g GALAXY\] PLANET ..."
33   exit 1
34 }
35 set g $galaxy1
36 for {set i 0} {$i < [llength $argv]} {incr i} {
37   set a [lindex $argv $i]
38   switch -- $a {
39     "-g" {
40       incr i
41       set a [lindex $argv $i]
42       set g [parse-galaxy-spec $a]
43       if {[string equal $g ""]} {
44         puts stderr "$argv0: bad galaxy string `$a'"
45         exit 1
46       }
47       destructure {. g} $g
48     }
49     default {
50       set n [parse-planet-spec $g $a]
51       if {[string equal $n ""]} {
52         puts stderr "$argv0: unknown planet `$a'"
53         continue
54       }
55       describe $n
56       puts ""
57     }
58   }
59 }