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